Completed
Branch master (c63335)
by
unknown
17:58 queued 13:20
created
core/CPTs/EE_CPT_Event_Strategy.core.php 2 patches
Indentation   +242 added lines, -242 removed lines patch added patch discarded remove patch
@@ -9,246 +9,246 @@
 block discarded – undo
9 9
  */
10 10
 class EE_CPT_Event_Strategy
11 11
 {
12
-    /**
13
-     * the current page, if it utilizes CPTs
14
-     *
15
-     * @var object $CPT
16
-     */
17
-    protected $CPT;
18
-
19
-
20
-    /**
21
-     * @param array|WP_Query|null $wp_query
22
-     * @param array         $CPT
23
-     */
24
-    public function __construct($wp_query, array $CPT = [])
25
-    {
26
-        if ($wp_query instanceof WP_Query) {
27
-            $WP_Query  = $wp_query;
28
-            $this->CPT = $CPT;
29
-        } else {
30
-            $WP_Query  = $wp_query['WP_Query'] ?? null;
31
-            $this->CPT = $wp_query['CPT'] ?? null;
32
-        }
33
-        // !!!!!!!!!!  IMPORTANT !!!!!!!!!!!!
34
-        // here's the list of available filters in the WP_Query object
35
-        // 'posts_where'
36
-        // 'posts_where_paged'
37
-        // 'posts_groupby'
38
-        // 'posts_join_paged'
39
-        // 'posts_orderby'
40
-        // 'posts_distinct'
41
-        // 'post_limits'
42
-        // 'posts_fields'
43
-        // 'posts_join'
44
-        $this->_add_filters();
45
-        if ($WP_Query instanceof WP_Query) {
46
-            $WP_Query->is_espresso_event_single   = is_singular()
47
-                                                    && isset($WP_Query->query->post_type)
48
-                                                    && $WP_Query->query->post_type === 'espresso_events';
49
-            $WP_Query->is_espresso_event_archive  = is_post_type_archive('espresso_events');
50
-            $WP_Query->is_espresso_event_taxonomy = is_tax('espresso_event_categories');
51
-        }
52
-    }
53
-
54
-
55
-    /**
56
-     * When an instance of this class is created, we add our filters
57
-     * (which will get removed in case the next call to get_posts ISN'T
58
-     * for event CPTs)
59
-     */
60
-    protected function _add_filters()
61
-    {
62
-        add_filter('posts_fields', [$this, 'posts_fields'], 1, 2);
63
-        add_filter('posts_join', [$this, 'posts_join'], 1, 2);
64
-        add_filter('posts_where', [$this, 'posts_where'], 10, 2);
65
-        // add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 );
66
-        add_filter('posts_orderby', [$this, 'posts_orderby'], 1, 2);
67
-        add_filter('posts_groupby', [$this, 'posts_groupby'], 1, 2);
68
-        add_action('posts_selection', [$this, 'remove_filters']);
69
-    }
70
-
71
-
72
-    /**
73
-     * public access to _remove_filters()
74
-     *
75
-     * @since 4.9.63.p
76
-     */
77
-    public function remove_filters()
78
-    {
79
-        $this->_remove_filters();
80
-    }
81
-
82
-
83
-    /**
84
-     * Should eb called when the last filter or hook is fired for this CPT strategy.
85
-     * This is to avoid applying this CPT strategy for other posts or CPTs (eg,
86
-     * we don't want to join to the datetime table when querying for venues, do we!?)
87
-     */
88
-    protected function _remove_filters()
89
-    {
90
-        remove_filter('posts_fields', [$this, 'posts_fields'], 1);
91
-        remove_filter('posts_join', [$this, 'posts_join'], 1);
92
-        remove_filter('posts_where', [$this, 'posts_where']);
93
-        // remove_filter( 'the_posts', array( $this, 'the_posts' ), 1 );
94
-        remove_filter('posts_orderby', [$this, 'posts_orderby'], 1);
95
-        remove_filter('posts_groupby', [$this, 'posts_groupby'], 1);
96
-        remove_action('posts_selection', [$this, 'remove_filters']);
97
-    }
98
-
99
-
100
-    /**
101
-     * @param string        $SQL
102
-     * @param WP_Query|null $wp_query
103
-     * @return    string
104
-     * @throws EE_Error
105
-     */
106
-    public function posts_fields(string $SQL, ?WP_Query $wp_query): string
107
-    {
108
-        if (
109
-            $wp_query instanceof WP_Query
110
-            && (
111
-                $wp_query->is_espresso_event_single
112
-                || $wp_query->is_espresso_event_archive
113
-                || $wp_query->is_espresso_event_taxonomy
114
-            )
115
-        ) {
116
-            // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement
117
-            $SQL .= ', ' . EEM_Datetime::instance()->table() . '.* ';
118
-            if ($wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy) {
119
-                // because we only want to retrieve the next upcoming datetime for each event:
120
-                // add something like:
121
-                // ", MIN( wp_esp_datetime.DTT_EVT_start ) as event_start_date "
122
-                // to WP Query SELECT statement
123
-                $SQL .= ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ';
124
-            }
125
-        }
126
-        return $SQL;
127
-    }
128
-
129
-
130
-    /**
131
-     * @param string        $SQL
132
-     * @param WP_Query|null $wp_query
133
-     * @return string
134
-     * @throws EE_Error
135
-     */
136
-    public function posts_join(string $SQL, ?WP_Query $wp_query): string
137
-    {
138
-        if (
139
-            $wp_query instanceof WP_Query
140
-            && (
141
-                $wp_query->is_espresso_event_single
142
-                || $wp_query->is_espresso_event_archive
143
-                || $wp_query->is_espresso_event_taxonomy
144
-            )
145
-        ) {
146
-            // adds something like:
147
-            // " LEFT JOIN wp_esp_datetime ON ( wp_esp_datetime.EVT_ID = wp_posts.ID ) "
148
-            // to WP Query JOIN statement
149
-            $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . EEM_Event::instance()->table()
150
-                    . '.ID = ' . EEM_Datetime::instance()->table() . '.'
151
-                    . EEM_Event::instance()->primary_key_name() . ' ) ';
152
-        }
153
-        return $SQL;
154
-    }
155
-
156
-
157
-    /**
158
-     * @param string        $SQL
159
-     * @param WP_Query|null $wp_query
160
-     * @return string
161
-     * @throws EE_Error
162
-     */
163
-    public function posts_where(string $SQL, ?WP_Query $wp_query): string
164
-    {
165
-        if (
166
-            $wp_query instanceof WP_Query
167
-            && (
168
-                $wp_query->is_espresso_event_archive
169
-                || $wp_query->is_espresso_event_taxonomy
170
-            )
171
-        ) {
172
-            if (
173
-                ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive)
174
-                || ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events)
175
-                || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events
176
-            ) {
177
-                $SQL .= ' AND ' . EEM_Datetime::instance()->table() . ".DTT_EVT_end > '"
178
-                        . current_time('mysql', true) . "' ";
179
-            }
180
-            // exclude trashed datetimes
181
-            $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_deleted = 0';
182
-        }
183
-        return $SQL;
184
-    }
185
-
186
-
187
-    /**
188
-     * @param string        $SQL
189
-     * @param WP_Query|null $wp_query
190
-     * @return string
191
-     */
192
-    public function posts_orderby(string $SQL, ?WP_Query $wp_query): string
193
-    {
194
-        if (
195
-            $wp_query instanceof WP_Query
196
-            && (
197
-                $wp_query->is_espresso_event_archive
198
-                || $wp_query->is_espresso_event_taxonomy
199
-            )
200
-        ) {
201
-            $SQL = ' event_start_date ASC ';
202
-        }
203
-        return $SQL;
204
-    }
205
-
206
-
207
-    /**
208
-     * @param string        $SQL
209
-     * @param WP_Query|null $wp_query
210
-     * @return string
211
-     */
212
-    public function posts_groupby(string $SQL, ?WP_Query $wp_query): string
213
-    {
214
-        if (
215
-            $wp_query instanceof WP_Query
216
-            && (
217
-                $wp_query->is_espresso_event_archive
218
-                || $wp_query->is_espresso_event_taxonomy
219
-            )
220
-        ) {
221
-            // TODO: add event list option for displaying ALL datetimes in event list or only primary datetime (default)
222
-            // we're joining to the datetimes table, where there can be MANY datetimes for a single event,
223
-            // but we want to only show each event only once
224
-            // (whereas if we didn't group them by the post's ID, then we would end up with many repeats)
225
-            global $wpdb;
226
-            $SQL = $wpdb->posts . '.ID ';
227
-        }
228
-        return $SQL;
229
-    }
230
-
231
-
232
-    /**
233
-     * @param array         $posts
234
-     * @param WP_Query|null $wp_query
235
-     * @return array
236
-     */
237
-    public function the_posts(array $posts, ?WP_Query $wp_query): array
238
-    {
239
-        return $posts;
240
-    }
241
-
242
-
243
-    /**
244
-     * @param mixed           $meta_value
245
-     * @param int|string      $post_id
246
-     * @param int|string      $meta_key
247
-     * @param bool|int|string $single
248
-     * @return mixed
249
-     */
250
-    public function get_EE_post_type_metadata($meta_value, $post_id, $meta_key, $single)
251
-    {
252
-        return $meta_value;
253
-    }
12
+	/**
13
+	 * the current page, if it utilizes CPTs
14
+	 *
15
+	 * @var object $CPT
16
+	 */
17
+	protected $CPT;
18
+
19
+
20
+	/**
21
+	 * @param array|WP_Query|null $wp_query
22
+	 * @param array         $CPT
23
+	 */
24
+	public function __construct($wp_query, array $CPT = [])
25
+	{
26
+		if ($wp_query instanceof WP_Query) {
27
+			$WP_Query  = $wp_query;
28
+			$this->CPT = $CPT;
29
+		} else {
30
+			$WP_Query  = $wp_query['WP_Query'] ?? null;
31
+			$this->CPT = $wp_query['CPT'] ?? null;
32
+		}
33
+		// !!!!!!!!!!  IMPORTANT !!!!!!!!!!!!
34
+		// here's the list of available filters in the WP_Query object
35
+		// 'posts_where'
36
+		// 'posts_where_paged'
37
+		// 'posts_groupby'
38
+		// 'posts_join_paged'
39
+		// 'posts_orderby'
40
+		// 'posts_distinct'
41
+		// 'post_limits'
42
+		// 'posts_fields'
43
+		// 'posts_join'
44
+		$this->_add_filters();
45
+		if ($WP_Query instanceof WP_Query) {
46
+			$WP_Query->is_espresso_event_single   = is_singular()
47
+													&& isset($WP_Query->query->post_type)
48
+													&& $WP_Query->query->post_type === 'espresso_events';
49
+			$WP_Query->is_espresso_event_archive  = is_post_type_archive('espresso_events');
50
+			$WP_Query->is_espresso_event_taxonomy = is_tax('espresso_event_categories');
51
+		}
52
+	}
53
+
54
+
55
+	/**
56
+	 * When an instance of this class is created, we add our filters
57
+	 * (which will get removed in case the next call to get_posts ISN'T
58
+	 * for event CPTs)
59
+	 */
60
+	protected function _add_filters()
61
+	{
62
+		add_filter('posts_fields', [$this, 'posts_fields'], 1, 2);
63
+		add_filter('posts_join', [$this, 'posts_join'], 1, 2);
64
+		add_filter('posts_where', [$this, 'posts_where'], 10, 2);
65
+		// add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 );
66
+		add_filter('posts_orderby', [$this, 'posts_orderby'], 1, 2);
67
+		add_filter('posts_groupby', [$this, 'posts_groupby'], 1, 2);
68
+		add_action('posts_selection', [$this, 'remove_filters']);
69
+	}
70
+
71
+
72
+	/**
73
+	 * public access to _remove_filters()
74
+	 *
75
+	 * @since 4.9.63.p
76
+	 */
77
+	public function remove_filters()
78
+	{
79
+		$this->_remove_filters();
80
+	}
81
+
82
+
83
+	/**
84
+	 * Should eb called when the last filter or hook is fired for this CPT strategy.
85
+	 * This is to avoid applying this CPT strategy for other posts or CPTs (eg,
86
+	 * we don't want to join to the datetime table when querying for venues, do we!?)
87
+	 */
88
+	protected function _remove_filters()
89
+	{
90
+		remove_filter('posts_fields', [$this, 'posts_fields'], 1);
91
+		remove_filter('posts_join', [$this, 'posts_join'], 1);
92
+		remove_filter('posts_where', [$this, 'posts_where']);
93
+		// remove_filter( 'the_posts', array( $this, 'the_posts' ), 1 );
94
+		remove_filter('posts_orderby', [$this, 'posts_orderby'], 1);
95
+		remove_filter('posts_groupby', [$this, 'posts_groupby'], 1);
96
+		remove_action('posts_selection', [$this, 'remove_filters']);
97
+	}
98
+
99
+
100
+	/**
101
+	 * @param string        $SQL
102
+	 * @param WP_Query|null $wp_query
103
+	 * @return    string
104
+	 * @throws EE_Error
105
+	 */
106
+	public function posts_fields(string $SQL, ?WP_Query $wp_query): string
107
+	{
108
+		if (
109
+			$wp_query instanceof WP_Query
110
+			&& (
111
+				$wp_query->is_espresso_event_single
112
+				|| $wp_query->is_espresso_event_archive
113
+				|| $wp_query->is_espresso_event_taxonomy
114
+			)
115
+		) {
116
+			// adds something like ", wp_esp_datetime.* " to WP Query SELECT statement
117
+			$SQL .= ', ' . EEM_Datetime::instance()->table() . '.* ';
118
+			if ($wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy) {
119
+				// because we only want to retrieve the next upcoming datetime for each event:
120
+				// add something like:
121
+				// ", MIN( wp_esp_datetime.DTT_EVT_start ) as event_start_date "
122
+				// to WP Query SELECT statement
123
+				$SQL .= ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ';
124
+			}
125
+		}
126
+		return $SQL;
127
+	}
128
+
129
+
130
+	/**
131
+	 * @param string        $SQL
132
+	 * @param WP_Query|null $wp_query
133
+	 * @return string
134
+	 * @throws EE_Error
135
+	 */
136
+	public function posts_join(string $SQL, ?WP_Query $wp_query): string
137
+	{
138
+		if (
139
+			$wp_query instanceof WP_Query
140
+			&& (
141
+				$wp_query->is_espresso_event_single
142
+				|| $wp_query->is_espresso_event_archive
143
+				|| $wp_query->is_espresso_event_taxonomy
144
+			)
145
+		) {
146
+			// adds something like:
147
+			// " LEFT JOIN wp_esp_datetime ON ( wp_esp_datetime.EVT_ID = wp_posts.ID ) "
148
+			// to WP Query JOIN statement
149
+			$SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . EEM_Event::instance()->table()
150
+					. '.ID = ' . EEM_Datetime::instance()->table() . '.'
151
+					. EEM_Event::instance()->primary_key_name() . ' ) ';
152
+		}
153
+		return $SQL;
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param string        $SQL
159
+	 * @param WP_Query|null $wp_query
160
+	 * @return string
161
+	 * @throws EE_Error
162
+	 */
163
+	public function posts_where(string $SQL, ?WP_Query $wp_query): string
164
+	{
165
+		if (
166
+			$wp_query instanceof WP_Query
167
+			&& (
168
+				$wp_query->is_espresso_event_archive
169
+				|| $wp_query->is_espresso_event_taxonomy
170
+			)
171
+		) {
172
+			if (
173
+				! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive)
174
+				|| ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events)
175
+				|| ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events
176
+			) {
177
+				$SQL .= ' AND ' . EEM_Datetime::instance()->table() . ".DTT_EVT_end > '"
178
+						. current_time('mysql', true) . "' ";
179
+			}
180
+			// exclude trashed datetimes
181
+			$SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_deleted = 0';
182
+		}
183
+		return $SQL;
184
+	}
185
+
186
+
187
+	/**
188
+	 * @param string        $SQL
189
+	 * @param WP_Query|null $wp_query
190
+	 * @return string
191
+	 */
192
+	public function posts_orderby(string $SQL, ?WP_Query $wp_query): string
193
+	{
194
+		if (
195
+			$wp_query instanceof WP_Query
196
+			&& (
197
+				$wp_query->is_espresso_event_archive
198
+				|| $wp_query->is_espresso_event_taxonomy
199
+			)
200
+		) {
201
+			$SQL = ' event_start_date ASC ';
202
+		}
203
+		return $SQL;
204
+	}
205
+
206
+
207
+	/**
208
+	 * @param string        $SQL
209
+	 * @param WP_Query|null $wp_query
210
+	 * @return string
211
+	 */
212
+	public function posts_groupby(string $SQL, ?WP_Query $wp_query): string
213
+	{
214
+		if (
215
+			$wp_query instanceof WP_Query
216
+			&& (
217
+				$wp_query->is_espresso_event_archive
218
+				|| $wp_query->is_espresso_event_taxonomy
219
+			)
220
+		) {
221
+			// TODO: add event list option for displaying ALL datetimes in event list or only primary datetime (default)
222
+			// we're joining to the datetimes table, where there can be MANY datetimes for a single event,
223
+			// but we want to only show each event only once
224
+			// (whereas if we didn't group them by the post's ID, then we would end up with many repeats)
225
+			global $wpdb;
226
+			$SQL = $wpdb->posts . '.ID ';
227
+		}
228
+		return $SQL;
229
+	}
230
+
231
+
232
+	/**
233
+	 * @param array         $posts
234
+	 * @param WP_Query|null $wp_query
235
+	 * @return array
236
+	 */
237
+	public function the_posts(array $posts, ?WP_Query $wp_query): array
238
+	{
239
+		return $posts;
240
+	}
241
+
242
+
243
+	/**
244
+	 * @param mixed           $meta_value
245
+	 * @param int|string      $post_id
246
+	 * @param int|string      $meta_key
247
+	 * @param bool|int|string $single
248
+	 * @return mixed
249
+	 */
250
+	public function get_EE_post_type_metadata($meta_value, $post_id, $meta_key, $single)
251
+	{
252
+		return $meta_value;
253
+	}
254 254
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
             )
115 115
         ) {
116 116
             // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement
117
-            $SQL .= ', ' . EEM_Datetime::instance()->table() . '.* ';
117
+            $SQL .= ', '.EEM_Datetime::instance()->table().'.* ';
118 118
             if ($wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy) {
119 119
                 // because we only want to retrieve the next upcoming datetime for each event:
120 120
                 // add something like:
121 121
                 // ", MIN( wp_esp_datetime.DTT_EVT_start ) as event_start_date "
122 122
                 // to WP Query SELECT statement
123
-                $SQL .= ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ';
123
+                $SQL .= ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date ';
124 124
             }
125 125
         }
126 126
         return $SQL;
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
             // adds something like:
147 147
             // " LEFT JOIN wp_esp_datetime ON ( wp_esp_datetime.EVT_ID = wp_posts.ID ) "
148 148
             // to WP Query JOIN statement
149
-            $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . EEM_Event::instance()->table()
150
-                    . '.ID = ' . EEM_Datetime::instance()->table() . '.'
151
-                    . EEM_Event::instance()->primary_key_name() . ' ) ';
149
+            $SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.EEM_Event::instance()->table()
150
+                    . '.ID = '.EEM_Datetime::instance()->table().'.'
151
+                    . EEM_Event::instance()->primary_key_name().' ) ';
152 152
         }
153 153
         return $SQL;
154 154
     }
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
                 || ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events)
175 175
                 || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events
176 176
             ) {
177
-                $SQL .= ' AND ' . EEM_Datetime::instance()->table() . ".DTT_EVT_end > '"
178
-                        . current_time('mysql', true) . "' ";
177
+                $SQL .= ' AND '.EEM_Datetime::instance()->table().".DTT_EVT_end > '"
178
+                        . current_time('mysql', true)."' ";
179 179
             }
180 180
             // exclude trashed datetimes
181
-            $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_deleted = 0';
181
+            $SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_deleted = 0';
182 182
         }
183 183
         return $SQL;
184 184
     }
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
             // but we want to only show each event only once
224 224
             // (whereas if we didn't group them by the post's ID, then we would end up with many repeats)
225 225
             global $wpdb;
226
-            $SQL = $wpdb->posts . '.ID ';
226
+            $SQL = $wpdb->posts.'.ID ';
227 227
         }
228 228
         return $SQL;
229 229
     }
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 its an AJAX request, or user is NOT an admin, or in full M-Mode
57
-        if (
58
-            defined('DOING_AJAX')
59
-            || ! $this->capabilities->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')
60
-            || EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance
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 of 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() === 'espresso_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' => EEM_Registration::status_id_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' => EEM_Registration::status_id_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', 'event_espresso'),
524
-                    'href'   => EEH_URL::add_query_args_and_nonce(
525
-                        [
526
-                            'action'      => 'default',
527
-                            'status'      => 'today',
528
-                            '_reg_status' => EEM_Registration::status_id_not_approved,
529
-                        ],
530
-                        $this->reg_admin_url
531
-                    ),
532
-                    'meta'   => [
533
-                        'title'  => esc_html__('Not Approved', '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' => EEM_Registration::status_id_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' => EEM_Registration::status_id_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' => EEM_Registration::status_id_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', 'event_espresso'),
702
-                    'href'   => EEH_URL::add_query_args_and_nonce(
703
-                        [
704
-                            'action'      => 'default',
705
-                            'status'      => 'month',
706
-                            '_reg_status' => EEM_Registration::status_id_not_approved,
707
-                        ],
708
-                        $this->reg_admin_url
709
-                    ),
710
-                    'meta'   => [
711
-                        'title'  => esc_html__('Not Approved', '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' => EEM_Registration::status_id_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 its an AJAX request, or user is NOT an admin, or in full M-Mode
57
+		if (
58
+			defined('DOING_AJAX')
59
+			|| ! $this->capabilities->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')
60
+			|| EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance
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 of 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() === 'espresso_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' => EEM_Registration::status_id_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' => EEM_Registration::status_id_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', 'event_espresso'),
524
+					'href'   => EEH_URL::add_query_args_and_nonce(
525
+						[
526
+							'action'      => 'default',
527
+							'status'      => 'today',
528
+							'_reg_status' => EEM_Registration::status_id_not_approved,
529
+						],
530
+						$this->reg_admin_url
531
+					),
532
+					'meta'   => [
533
+						'title'  => esc_html__('Not Approved', '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' => EEM_Registration::status_id_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' => EEM_Registration::status_id_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' => EEM_Registration::status_id_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', 'event_espresso'),
702
+					'href'   => EEH_URL::add_query_args_and_nonce(
703
+						[
704
+							'action'      => 'default',
705
+							'status'      => 'month',
706
+							'_reg_status' => EEM_Registration::status_id_not_approved,
707
+						],
708
+						$this->reg_admin_url
709
+					),
710
+					'meta'   => [
711
+						'title'  => esc_html__('Not Approved', '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' => EEM_Registration::status_id_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', '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', '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.
core/domain/services/messages/MessageTemplateRequestData.php 1 patch
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -14,262 +14,262 @@
 block discarded – undo
14 14
  */
15 15
 class MessageTemplateRequestData
16 16
 {
17
-    protected ?RequestInterface $request         = null;
17
+	protected ?RequestInterface $request         = null;
18 18
 
19
-    protected string            $context         = '';
19
+	protected string            $context         = '';
20 20
 
21
-    protected string            $description     = '';
21
+	protected string            $description     = '';
22 22
 
23
-    protected string            $messenger       = '';
23
+	protected string            $messenger       = '';
24 24
 
25
-    protected string            $message_type    = '';
25
+	protected string            $message_type    = '';
26 26
 
27
-    protected string            $name            = '';
27
+	protected string            $name            = '';
28 28
 
29
-    protected array             $template_fields = [];
29
+	protected array             $template_fields = [];
30 30
 
31
-    protected int               $group_ID        = 0;
31
+	protected int               $group_ID        = 0;
32 32
 
33
-    protected int               $user_ID         = 0;
33
+	protected int               $user_ID         = 0;
34 34
 
35
-    protected bool              $is_active       = false;
35
+	protected bool              $is_active       = false;
36 36
 
37
-    protected bool              $is_deleted      = false;
37
+	protected bool              $is_deleted      = false;
38 38
 
39
-    protected bool              $is_global       = false;
39
+	protected bool              $is_global       = false;
40 40
 
41
-    protected bool              $is_override     = false;
41
+	protected bool              $is_override     = false;
42 42
 
43 43
 
44
-    /**
45
-     * @param RequestInterface|null $request
46
-     */
47
-    public function __construct(?RequestInterface $request)
48
-    {
49
-        $this->request = $request;
50
-    }
44
+	/**
45
+	 * @param RequestInterface|null $request
46
+	 */
47
+	public function __construct(?RequestInterface $request)
48
+	{
49
+		$this->request = $request;
50
+	}
51 51
 
52 52
 
53
-    public function setMessageTemplateRequestData()
54
-    {
55
-        $this->setContext();
56
-        $this->setDescription();
57
-        $this->setGroupID();
58
-        $this->setIsActive();
59
-        $this->setIsDeleted();
60
-        $this->setIsGlobal();
61
-        $this->setIsOverride();
62
-        $this->setMessenger();
63
-        $this->setMessageType();
64
-        $this->setName();
65
-        $this->setUserID();
66
-        $this->setTemplateFields();
67
-    }
53
+	public function setMessageTemplateRequestData()
54
+	{
55
+		$this->setContext();
56
+		$this->setDescription();
57
+		$this->setGroupID();
58
+		$this->setIsActive();
59
+		$this->setIsDeleted();
60
+		$this->setIsGlobal();
61
+		$this->setIsOverride();
62
+		$this->setMessenger();
63
+		$this->setMessageType();
64
+		$this->setName();
65
+		$this->setUserID();
66
+		$this->setTemplateFields();
67
+	}
68 68
 
69 69
 
70
-    public function context(): string
71
-    {
72
-        return $this->context;
73
-    }
70
+	public function context(): string
71
+	{
72
+		return $this->context;
73
+	}
74 74
 
75 75
 
76
-    public function description(): string
77
-    {
78
-        return $this->description;
79
-    }
76
+	public function description(): string
77
+	{
78
+		return $this->description;
79
+	}
80 80
 
81 81
 
82
-    public function messenger(): string
83
-    {
84
-        return $this->messenger;
85
-    }
82
+	public function messenger(): string
83
+	{
84
+		return $this->messenger;
85
+	}
86 86
 
87 87
 
88
-    public function messageType(): string
89
-    {
90
-        return $this->message_type;
91
-    }
88
+	public function messageType(): string
89
+	{
90
+		return $this->message_type;
91
+	}
92 92
 
93 93
 
94
-    public function name(): string
95
-    {
96
-        return $this->name;
97
-    }
94
+	public function name(): string
95
+	{
96
+		return $this->name;
97
+	}
98 98
 
99 99
 
100
-    public function templateFields(): array
101
-    {
102
-        return $this->template_fields;
103
-    }
100
+	public function templateFields(): array
101
+	{
102
+		return $this->template_fields;
103
+	}
104 104
 
105 105
 
106
-    public function groupID(): int
107
-    {
108
-        return $this->group_ID;
109
-    }
106
+	public function groupID(): int
107
+	{
108
+		return $this->group_ID;
109
+	}
110 110
 
111 111
 
112
-    public function userID(): int
113
-    {
114
-        return $this->user_ID;
115
-    }
112
+	public function userID(): int
113
+	{
114
+		return $this->user_ID;
115
+	}
116 116
 
117 117
 
118
-    public function isActive(): bool
119
-    {
120
-        return $this->is_active;
121
-    }
118
+	public function isActive(): bool
119
+	{
120
+		return $this->is_active;
121
+	}
122 122
 
123 123
 
124
-    public function isDeleted(): bool
125
-    {
126
-        return $this->is_deleted;
127
-    }
124
+	public function isDeleted(): bool
125
+	{
126
+		return $this->is_deleted;
127
+	}
128 128
 
129 129
 
130
-    public function isGlobal(): bool
131
-    {
132
-        return $this->is_global;
133
-    }
130
+	public function isGlobal(): bool
131
+	{
132
+		return $this->is_global;
133
+	}
134 134
 
135 135
 
136
-    public function isOverride(): bool
137
-    {
138
-        return $this->is_override;
139
-    }
136
+	public function isOverride(): bool
137
+	{
138
+		return $this->is_override;
139
+	}
140 140
 
141 141
 
142
-    public function setContext(?string $context = ''): void
143
-    {
144
-        $this->context = $this->request->getRequestParam('context', $context);
145
-        $this->context = $this->request->getRequestParam('MTP_context', $this->context);
146
-        $this->context = strtolower($this->context);
147
-    }
142
+	public function setContext(?string $context = ''): void
143
+	{
144
+		$this->context = $this->request->getRequestParam('context', $context);
145
+		$this->context = $this->request->getRequestParam('MTP_context', $this->context);
146
+		$this->context = strtolower($this->context);
147
+	}
148 148
 
149 149
 
150
-    public function setDescription(?string $description = ''): void
151
-    {
152
-        $this->description = $this->request->getRequestParam(
153
-            'ee_msg_non_global_fields[MTP_description]',
154
-            $description
155
-        );
156
-    }
157
-
158
-
159
-    public function setGroupID(?int $group_ID = 0): void
160
-    {
161
-        $this->group_ID = $this->request->getRequestParam('group_ID', $group_ID, DataType::INTEGER);
162
-        $this->group_ID = $this->request->getRequestParam('GRP_ID', $this->group_ID, DataType::INTEGER);
163
-        // we need the GRP_ID for the template being used as the base for the new template
164
-        if (empty($this->group_ID)) {
165
-            throw new RuntimeException(
166
-                esc_html__(
167
-                    'In order to create a custom message template the GRP_ID of the template being used as a base is needed',
168
-                    'event_espresso'
169
-                )
170
-            );
171
-        }
172
-    }
173
-
174
-
175
-    public function setIsActive(bool $is_active = false): void
176
-    {
177
-        $this->is_active = $this->request->getRequestParam('MTP_is_active', $is_active, DataType::BOOLEAN);
178
-    }
179
-
180
-
181
-    public function setIsDeleted(bool $is_deleted = false): void
182
-    {
183
-        $this->is_deleted = $this->request->getRequestParam('MTP_deleted', $is_deleted, DataType::BOOLEAN);
184
-    }
185
-
186
-
187
-    public function setIsGlobal(bool $is_global = false): void
188
-    {
189
-        $this->is_global = $this->request->getRequestParam('MTP_is_global', $is_global, DataType::BOOLEAN);
190
-    }
191
-
192
-
193
-    public function setIsOverride(bool $is_override = false): void
194
-    {
195
-        $this->is_override = $this->request->getRequestParam('MTP_is_override', $is_override, DataType::BOOLEAN);
196
-    }
197
-
198
-
199
-    public function setMessenger(?string $messenger = ''): void
200
-    {
201
-        // have to check for multiple params because a previouv dev used different names for the same param >:(
202
-        $this->messenger = $this->request->getRequestParam('msgr', $messenger);
203
-        $this->messenger = $this->request->getRequestParam('messenger', $this->messenger);
204
-        $this->messenger = $this->request->getRequestParam('MTP_messenger', $this->messenger);
205
-        $this->messenger = strtolower($this->messenger);
206
-        if (empty($this->messenger)) {
207
-            throw new RuntimeException(
208
-                esc_html__(
209
-                    'Sorry, but we can\'t create new templates because we\'re missing the messenger',
210
-                    'event_espresso'
211
-                )
212
-            );
213
-        }
214
-    }
215
-
216
-
217
-    public function setMessageType(?string $message_type = ''): void
218
-    {
219
-        // have to check for multiple params because a previouv dev used different names for the same param >:(
220
-        $this->message_type = $this->request->getRequestParam('mt', $message_type);
221
-        $this->message_type = $this->request->getRequestParam('message_type', $this->message_type);
222
-        $this->message_type = $this->request->getRequestParam('messageType', $this->message_type);
223
-        $this->message_type = $this->request->getRequestParam('MTP_message_type', $this->message_type);
224
-        $this->message_type = strtolower($this->message_type);
225
-
226
-        if (empty($this->message_type)) {
227
-            throw new RuntimeException(
228
-                esc_html__(
229
-                    'Sorry, but we can\'t create new templates because we\'re missing the message type',
230
-                    'event_espresso'
231
-                )
232
-            );
233
-        }
234
-    }
235
-
236
-
237
-    public function setName(?string $name = ''): void
238
-    {
239
-        $this->name = $this->request->getRequestParam('ee_msg_non_global_fields[MTP_name]', $name);
240
-    }
241
-
242
-
243
-    public function setUserID(?int $user_ID = 0): void
244
-    {
245
-        $this->user_ID = $this->request->getRequestParam('user_id', $user_ID, DataType::INTEGER);
246
-        $this->user_ID = $this->request->getRequestParam('MTP_user_id', $this->user_ID, DataType::INTEGER);
247
-    }
248
-
249
-
250
-    private function setTemplateFields(): void
251
-    {
252
-        $this->template_fields = $this->request->getRequestParam(
253
-            'template_fields',
254
-            null,
255
-            DataType::EDITOR,
256
-            true
257
-        );
258
-        $this->template_fields = $this->request->getRequestParam(
259
-            'MTP_template_fields',
260
-            $this->template_fields,
261
-            DataType::EDITOR,
262
-            true
263
-        );
264
-        if (empty($this->template_fields)) {
265
-            throw new RuntimeException(
266
-                esc_html__(
267
-                    'There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.',
268
-                    'event_espresso'
269
-                )
270
-            );
271
-        }
272
-        // messages content is expected to be escaped
273
-        $this->template_fields = EEH_Array::addSlashesRecursively($this->template_fields);
274
-    }
150
+	public function setDescription(?string $description = ''): void
151
+	{
152
+		$this->description = $this->request->getRequestParam(
153
+			'ee_msg_non_global_fields[MTP_description]',
154
+			$description
155
+		);
156
+	}
157
+
158
+
159
+	public function setGroupID(?int $group_ID = 0): void
160
+	{
161
+		$this->group_ID = $this->request->getRequestParam('group_ID', $group_ID, DataType::INTEGER);
162
+		$this->group_ID = $this->request->getRequestParam('GRP_ID', $this->group_ID, DataType::INTEGER);
163
+		// we need the GRP_ID for the template being used as the base for the new template
164
+		if (empty($this->group_ID)) {
165
+			throw new RuntimeException(
166
+				esc_html__(
167
+					'In order to create a custom message template the GRP_ID of the template being used as a base is needed',
168
+					'event_espresso'
169
+				)
170
+			);
171
+		}
172
+	}
173
+
174
+
175
+	public function setIsActive(bool $is_active = false): void
176
+	{
177
+		$this->is_active = $this->request->getRequestParam('MTP_is_active', $is_active, DataType::BOOLEAN);
178
+	}
179
+
180
+
181
+	public function setIsDeleted(bool $is_deleted = false): void
182
+	{
183
+		$this->is_deleted = $this->request->getRequestParam('MTP_deleted', $is_deleted, DataType::BOOLEAN);
184
+	}
185
+
186
+
187
+	public function setIsGlobal(bool $is_global = false): void
188
+	{
189
+		$this->is_global = $this->request->getRequestParam('MTP_is_global', $is_global, DataType::BOOLEAN);
190
+	}
191
+
192
+
193
+	public function setIsOverride(bool $is_override = false): void
194
+	{
195
+		$this->is_override = $this->request->getRequestParam('MTP_is_override', $is_override, DataType::BOOLEAN);
196
+	}
197
+
198
+
199
+	public function setMessenger(?string $messenger = ''): void
200
+	{
201
+		// have to check for multiple params because a previouv dev used different names for the same param >:(
202
+		$this->messenger = $this->request->getRequestParam('msgr', $messenger);
203
+		$this->messenger = $this->request->getRequestParam('messenger', $this->messenger);
204
+		$this->messenger = $this->request->getRequestParam('MTP_messenger', $this->messenger);
205
+		$this->messenger = strtolower($this->messenger);
206
+		if (empty($this->messenger)) {
207
+			throw new RuntimeException(
208
+				esc_html__(
209
+					'Sorry, but we can\'t create new templates because we\'re missing the messenger',
210
+					'event_espresso'
211
+				)
212
+			);
213
+		}
214
+	}
215
+
216
+
217
+	public function setMessageType(?string $message_type = ''): void
218
+	{
219
+		// have to check for multiple params because a previouv dev used different names for the same param >:(
220
+		$this->message_type = $this->request->getRequestParam('mt', $message_type);
221
+		$this->message_type = $this->request->getRequestParam('message_type', $this->message_type);
222
+		$this->message_type = $this->request->getRequestParam('messageType', $this->message_type);
223
+		$this->message_type = $this->request->getRequestParam('MTP_message_type', $this->message_type);
224
+		$this->message_type = strtolower($this->message_type);
225
+
226
+		if (empty($this->message_type)) {
227
+			throw new RuntimeException(
228
+				esc_html__(
229
+					'Sorry, but we can\'t create new templates because we\'re missing the message type',
230
+					'event_espresso'
231
+				)
232
+			);
233
+		}
234
+	}
235
+
236
+
237
+	public function setName(?string $name = ''): void
238
+	{
239
+		$this->name = $this->request->getRequestParam('ee_msg_non_global_fields[MTP_name]', $name);
240
+	}
241
+
242
+
243
+	public function setUserID(?int $user_ID = 0): void
244
+	{
245
+		$this->user_ID = $this->request->getRequestParam('user_id', $user_ID, DataType::INTEGER);
246
+		$this->user_ID = $this->request->getRequestParam('MTP_user_id', $this->user_ID, DataType::INTEGER);
247
+	}
248
+
249
+
250
+	private function setTemplateFields(): void
251
+	{
252
+		$this->template_fields = $this->request->getRequestParam(
253
+			'template_fields',
254
+			null,
255
+			DataType::EDITOR,
256
+			true
257
+		);
258
+		$this->template_fields = $this->request->getRequestParam(
259
+			'MTP_template_fields',
260
+			$this->template_fields,
261
+			DataType::EDITOR,
262
+			true
263
+		);
264
+		if (empty($this->template_fields)) {
265
+			throw new RuntimeException(
266
+				esc_html__(
267
+					'There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.',
268
+					'event_espresso'
269
+				)
270
+			);
271
+		}
272
+		// messages content is expected to be escaped
273
+		$this->template_fields = EEH_Array::addSlashesRecursively($this->template_fields);
274
+	}
275 275
 }
Please login to merge, or discard this patch.
core/domain/services/messages/MessageTemplateManager.php 1 patch
Indentation   +335 added lines, -335 removed lines patch added patch discarded remove patch
@@ -17,339 +17,339 @@
 block discarded – undo
17 17
  */
18 18
 class MessageTemplateManager
19 19
 {
20
-    private EEM_Message_Template         $message_template_model;
21
-
22
-    private EEM_Message_Template_Group   $message_template_group_model;
23
-
24
-    protected MessageTemplateRequestData $form_data;
25
-
26
-    protected MessageTemplateValidator   $validator;
27
-
28
-    protected RequestInterface           $request;
29
-
30
-
31
-    /**
32
-     * @param EEM_Message_Template       $message_template_model
33
-     * @param EEM_Message_Template_Group $message_template_group_model
34
-     * @param MessageTemplateRequestData $form_data
35
-     * @param MessageTemplateValidator   $validator
36
-     * @param RequestInterface           $request
37
-     */
38
-    public function __construct(
39
-        EEM_Message_Template $message_template_model,
40
-        EEM_Message_Template_Group $message_template_group_model,
41
-        MessageTemplateRequestData $form_data,
42
-        MessageTemplateValidator $validator,
43
-        RequestInterface $request
44
-    ) {
45
-        $this->message_template_model       = $message_template_model;
46
-        $this->message_template_group_model = $message_template_group_model;
47
-        $this->form_data                    = $form_data;
48
-        $this->validator                    = $validator;
49
-        $this->request                      = $request;
50
-    }
51
-
52
-
53
-    /**
54
-     * @param string|null $messenger
55
-     * @param string|null $message_type
56
-     * @param int         $GRP_ID
57
-     * @param bool        $global
58
-     * @return array
59
-     * @throws EE_Error
60
-     * @throws ReflectionException
61
-     */
62
-    public function generateNewTemplates(
63
-        ?string $messenger = '',
64
-        ?string $message_type = '',
65
-        int $GRP_ID = 0,
66
-        bool $global = false
67
-    ): array {
68
-        $this->form_data->setMessageTemplateRequestData();
69
-
70
-        $messenger    = $messenger ?: $this->form_data->messenger();
71
-        $message_type = $message_type ?: $this->form_data->messageType();
72
-        $GRP_ID       = $GRP_ID ?: $this->form_data->groupID();
73
-
74
-        // if no $message_types are given then that's okay...
75
-        // this may be a messenger that just adds shortcodes,
76
-        // so we just don't generate any templates.
77
-        if (empty($message_type)) {
78
-            return [];
79
-        }
80
-        $new_templates = EEH_MSG_Template::generate_new_templates($messenger, [$message_type], $GRP_ID, $global);
81
-        return $new_templates[0];
82
-    }
83
-
84
-
85
-    /**
86
-     * @throws DomainException
87
-     * @throws EE_Error
88
-     * @throws ReflectionException
89
-     */
90
-    public function updateExistingTemplates(): void
91
-    {
92
-        $this->form_data->setMessageTemplateRequestData();
93
-        $template_fields = $this->form_data->templateFields();
94
-
95
-        if ($template_fields) {
96
-            if (
97
-                $this->validator->validateTemplateFields(
98
-                    $this->form_data->messenger(),
99
-                    $this->form_data->messageType(),
100
-                    $this->form_data->context(),
101
-                    $template_fields
102
-                )
103
-            ) {
104
-                foreach ($template_fields as $template_field => $data) {
105
-                    $this->validateTemplateFieldData($template_field, $data);
106
-                    $this->updateMessageTemplate(
107
-                        $template_field,
108
-                        [
109
-                            'GRP_ID'             => $this->form_data->groupID(),
110
-                            'MTP_ID'             => $data['MTP_ID'],
111
-                            'MTP_template_field' => $data['name'],
112
-                            'MTP_context'        => $this->form_data->context(),
113
-                            // if they aren't allowed to use all JS, restrict them to standard allowed post tags
114
-                            'MTP_content'        => ! current_user_can('unfiltered_html')
115
-                                ? $this->sanitizeMessageTemplateContent($data['content'])
116
-                                : $data['content'],
117
-                        ]
118
-                    );
119
-                }
120
-                // we can use the last set_column_values for the Message Template Group update
121
-                // (because its the same for all of these specific MTPs)
122
-                $this->updateMessageTemplateGroup(
123
-                    [
124
-                        'GRP_ID'           => $this->form_data->groupID(),
125
-                        'MTP_user_id'      => $this->form_data->userID(),
126
-                        'MTP_messenger'    => $this->form_data->messenger(),
127
-                        'MTP_message_type' => $this->form_data->messageType(),
128
-                        'MTP_is_global'    => $this->form_data->isGlobal(),
129
-                        'MTP_is_override'  => $this->form_data->isOverride(),
130
-                        'MTP_deleted'      => $this->form_data->isDeleted(),
131
-                        'MTP_is_active'    => $this->form_data->isActive(),
132
-                        'MTP_name'         => $this->form_data->name(),
133
-                        'MTP_description'  => $this->form_data->description(),
134
-                    ]
135
-                );
136
-            }
137
-        }
138
-    }
139
-
140
-
141
-    /**
142
-     * @param string $template_field
143
-     * @param array  $message_template_fields
144
-     * @return void
145
-     * @throws EE_Error
146
-     * @throws ReflectionException
147
-     */
148
-    private function updateMessageTemplate(string $template_field, array $message_template_fields): void
149
-    {
150
-        $MTP_ID = $message_template_fields['MTP_ID'] ?? 0;
151
-        // if we have a MTP_ID for this field then update it, otherwise insert.
152
-        // this has already been through the template field validator and sanitized, so it will be
153
-        // safe to insert this field.  Why insert?  This typically happens when we introduce a new
154
-        // message template field in a messenger/message type and existing users don't have the
155
-        // default setup for it.
156
-        // @link https://events.codebasehq.com/projects/event-espresso/tickets/9465
157
-        $updated = $MTP_ID
158
-            ? $this->message_template_model->update($message_template_fields, [['MTP_ID' => $MTP_ID]])
159
-            : $this->message_template_model->insert($message_template_fields);
160
-
161
-        // updates will return 0 if the field was not changed (ie: no changes = nothing actually updated)
162
-        // but we won't consider that a problem, but if it returns false, then something went BOOM!
163
-        if ($updated === false) {
164
-            EE_Error::add_error(
165
-                sprintf(
166
-                    esc_html__('%s field was NOT updated for some reason', 'event_espresso'),
167
-                    $template_field
168
-                ),
169
-                __FILE__,
170
-                __FUNCTION__,
171
-                __LINE__
172
-            );
173
-        }
174
-    }
175
-
176
-
177
-    /**
178
-     * @param array $form_data
179
-     * @return void
180
-     * @throws EE_Error
181
-     * @throws ReflectionException
182
-     */
183
-    private function updateMessageTemplateGroup(array $form_data): void
184
-    {
185
-        try {
186
-            $GRP_ID = $form_data['id'] ?? 0;
187
-            $GRP_ID = $form_data['GRP_ID'] ?? $GRP_ID;
188
-            if (! $GRP_ID) {
189
-                throw new RuntimeException(
190
-                    esc_html__(
191
-                        'Can not update message template group because no GRP_ID was provided',
192
-                        'event_espresso'
193
-                    )
194
-                );
195
-            }
196
-
197
-            $updated       = $this->message_template_group_model->update($form_data, [['GRP_ID' => $GRP_ID]]);
198
-            $error_message = esc_html__(
199
-                'unknown error occurred while updating message template group',
200
-                'event_espresso'
201
-            );
202
-
203
-            if ($updated !== false) {
204
-                $message_template_group = $this->message_template_group_model->get_one_by_ID($GRP_ID);
205
-                if ($message_template_group instanceof EE_Message_Template_Group) {
206
-                    // k now we need to ensure the template_pack and template_variation fields are set.
207
-                    $template_pack      = $this->request->getRequestParam('MTP_template_pack', 'default');
208
-                    $template_variation = $this->request->getRequestParam('MTP_template_variation', 'default');
209
-                    $message_template_group->set_template_pack_name($template_pack);
210
-                    $message_template_group->set_template_pack_variation($template_variation);
211
-                }
212
-                return;
213
-            }
214
-        } catch (RuntimeException $exception) {
215
-            $error_message = $exception->getMessage();
216
-        }
217
-
218
-        EE_Error::add_error(
219
-            sprintf(
220
-                esc_html__(
221
-                    'The Message Template Group (%1$d) was NOT updated for the following reason: %2$s',
222
-                    'event_espresso'
223
-                ),
224
-                $form_data['GRP_ID'],
225
-                $error_message
226
-            ),
227
-            __FILE__,
228
-            __FUNCTION__,
229
-            __LINE__
230
-        );
231
-    }
232
-
233
-
234
-    /**
235
-     * recursively runs wp_kses() on message template content in a model safe manner
236
-     *
237
-     * @param array|string $content
238
-     * @return array|string
239
-     * @since   4.10.29.p
240
-     */
241
-    private function sanitizeMessageTemplateContent($content)
242
-    {
243
-        if (is_array($content)) {
244
-            foreach ($content as $key => $value) {
245
-                $content[ $key ] = $this->sanitizeMessageTemplateContent($value);
246
-            }
247
-            return $content;
248
-        }
249
-        // remove slashes so wp_kses() works properly
250
-        // wp_kses_stripslashes() only removes slashes from double-quotes,
251
-        // so attributes using single quotes always appear invalid.
252
-        $content = stripslashes($content);
253
-        $content = wp_kses($content, wp_kses_allowed_html('post'));
254
-        // But currently the models expect slashed data, so after wp_kses()
255
-        // runs we need to re-slash the data. Sheesh.
256
-        // See https://events.codebasehq.com/projects/event-espresso/tickets/11211#update-47321587
257
-        return addslashes($content);
258
-    }
259
-
260
-
261
-    /**
262
-     * @param int $GRP_ID
263
-     * @return false|int
264
-     * @throws EE_Error
265
-     * @throws ReflectionException
266
-     */
267
-    public function trashMessageTemplate(int $GRP_ID)
268
-    {
269
-        return $this->message_template_group_model->delete_by_ID($GRP_ID);
270
-    }
271
-
272
-
273
-    /**
274
-     * @param int $GRP_ID
275
-     * @return bool
276
-     * @throws EE_Error
277
-     */
278
-    public function restoreMessageTemplate(int $GRP_ID): bool
279
-    {
280
-        return $this->message_template_group_model->restore_by_ID($GRP_ID);
281
-    }
282
-
283
-
284
-    /**
285
-     * @param int $GRP_ID
286
-     * @return EE_Message_Template_Group
287
-     * @throws EE_Error
288
-     * @throws ReflectionException
289
-     */
290
-    private function getMessageTemplateGroup(int $GRP_ID): EE_Message_Template_Group
291
-    {
292
-        $message_template_group = $this->message_template_group_model->get_one_by_ID($GRP_ID);
293
-        if ($message_template_group instanceof EE_Message_Template_Group) {
294
-            return $message_template_group;
295
-        }
296
-        throw new RuntimeException(
297
-            esc_html__(
298
-                'Can not permanently delete message template group because an invalid GRP_ID was provided',
299
-                'event_espresso'
300
-            )
301
-        );
302
-    }
303
-
304
-
305
-    /**
306
-     * @param int $GRP_ID
307
-     * @return bool
308
-     * @throws EE_Error
309
-     * @throws ReflectionException
310
-     */
311
-    public function permanentlyDeleteMessageTemplates(int $GRP_ID): bool
312
-    {
313
-        $message_template_group = $this->getMessageTemplateGroup($GRP_ID);
314
-        // permanently delete all the related Message Templates
315
-        $deleted = $message_template_group->delete_related_permanently('Message_Template');
316
-        return $deleted > 0;
317
-    }
318
-
319
-
320
-    /**
321
-     * @param int $GRP_ID
322
-     * @return bool
323
-     * @throws EE_Error
324
-     * @throws ReflectionException
325
-     */
326
-    public function permanentlyDeleteMessageTemplateGroup(int $GRP_ID): bool
327
-    {
328
-        if ($this->permanentlyDeleteMessageTemplates($GRP_ID)) {
329
-            return $this->message_template_group_model->delete_permanently([['GRP_ID' => $GRP_ID]]);
330
-        }
331
-        return false;
332
-    }
333
-
334
-
335
-    private function validateTemplateFieldData(string $template_field, array $data)
336
-    {
337
-        if (
338
-            ! (
339
-                array_key_exists('MTP_ID', $data)
340
-                && array_key_exists('name', $data)
341
-                && array_key_exists('content', $data)
342
-            )
343
-        ) {
344
-            throw new RuntimeException(
345
-                sprintf(
346
-                    esc_html__(
347
-                        'Can not update message template field %1$s because of a missing MTP_ID, name, or content.',
348
-                        'event_espresso'
349
-                    ),
350
-                    $template_field
351
-                )
352
-            );
353
-        }
354
-    }
20
+	private EEM_Message_Template         $message_template_model;
21
+
22
+	private EEM_Message_Template_Group   $message_template_group_model;
23
+
24
+	protected MessageTemplateRequestData $form_data;
25
+
26
+	protected MessageTemplateValidator   $validator;
27
+
28
+	protected RequestInterface           $request;
29
+
30
+
31
+	/**
32
+	 * @param EEM_Message_Template       $message_template_model
33
+	 * @param EEM_Message_Template_Group $message_template_group_model
34
+	 * @param MessageTemplateRequestData $form_data
35
+	 * @param MessageTemplateValidator   $validator
36
+	 * @param RequestInterface           $request
37
+	 */
38
+	public function __construct(
39
+		EEM_Message_Template $message_template_model,
40
+		EEM_Message_Template_Group $message_template_group_model,
41
+		MessageTemplateRequestData $form_data,
42
+		MessageTemplateValidator $validator,
43
+		RequestInterface $request
44
+	) {
45
+		$this->message_template_model       = $message_template_model;
46
+		$this->message_template_group_model = $message_template_group_model;
47
+		$this->form_data                    = $form_data;
48
+		$this->validator                    = $validator;
49
+		$this->request                      = $request;
50
+	}
51
+
52
+
53
+	/**
54
+	 * @param string|null $messenger
55
+	 * @param string|null $message_type
56
+	 * @param int         $GRP_ID
57
+	 * @param bool        $global
58
+	 * @return array
59
+	 * @throws EE_Error
60
+	 * @throws ReflectionException
61
+	 */
62
+	public function generateNewTemplates(
63
+		?string $messenger = '',
64
+		?string $message_type = '',
65
+		int $GRP_ID = 0,
66
+		bool $global = false
67
+	): array {
68
+		$this->form_data->setMessageTemplateRequestData();
69
+
70
+		$messenger    = $messenger ?: $this->form_data->messenger();
71
+		$message_type = $message_type ?: $this->form_data->messageType();
72
+		$GRP_ID       = $GRP_ID ?: $this->form_data->groupID();
73
+
74
+		// if no $message_types are given then that's okay...
75
+		// this may be a messenger that just adds shortcodes,
76
+		// so we just don't generate any templates.
77
+		if (empty($message_type)) {
78
+			return [];
79
+		}
80
+		$new_templates = EEH_MSG_Template::generate_new_templates($messenger, [$message_type], $GRP_ID, $global);
81
+		return $new_templates[0];
82
+	}
83
+
84
+
85
+	/**
86
+	 * @throws DomainException
87
+	 * @throws EE_Error
88
+	 * @throws ReflectionException
89
+	 */
90
+	public function updateExistingTemplates(): void
91
+	{
92
+		$this->form_data->setMessageTemplateRequestData();
93
+		$template_fields = $this->form_data->templateFields();
94
+
95
+		if ($template_fields) {
96
+			if (
97
+				$this->validator->validateTemplateFields(
98
+					$this->form_data->messenger(),
99
+					$this->form_data->messageType(),
100
+					$this->form_data->context(),
101
+					$template_fields
102
+				)
103
+			) {
104
+				foreach ($template_fields as $template_field => $data) {
105
+					$this->validateTemplateFieldData($template_field, $data);
106
+					$this->updateMessageTemplate(
107
+						$template_field,
108
+						[
109
+							'GRP_ID'             => $this->form_data->groupID(),
110
+							'MTP_ID'             => $data['MTP_ID'],
111
+							'MTP_template_field' => $data['name'],
112
+							'MTP_context'        => $this->form_data->context(),
113
+							// if they aren't allowed to use all JS, restrict them to standard allowed post tags
114
+							'MTP_content'        => ! current_user_can('unfiltered_html')
115
+								? $this->sanitizeMessageTemplateContent($data['content'])
116
+								: $data['content'],
117
+						]
118
+					);
119
+				}
120
+				// we can use the last set_column_values for the Message Template Group update
121
+				// (because its the same for all of these specific MTPs)
122
+				$this->updateMessageTemplateGroup(
123
+					[
124
+						'GRP_ID'           => $this->form_data->groupID(),
125
+						'MTP_user_id'      => $this->form_data->userID(),
126
+						'MTP_messenger'    => $this->form_data->messenger(),
127
+						'MTP_message_type' => $this->form_data->messageType(),
128
+						'MTP_is_global'    => $this->form_data->isGlobal(),
129
+						'MTP_is_override'  => $this->form_data->isOverride(),
130
+						'MTP_deleted'      => $this->form_data->isDeleted(),
131
+						'MTP_is_active'    => $this->form_data->isActive(),
132
+						'MTP_name'         => $this->form_data->name(),
133
+						'MTP_description'  => $this->form_data->description(),
134
+					]
135
+				);
136
+			}
137
+		}
138
+	}
139
+
140
+
141
+	/**
142
+	 * @param string $template_field
143
+	 * @param array  $message_template_fields
144
+	 * @return void
145
+	 * @throws EE_Error
146
+	 * @throws ReflectionException
147
+	 */
148
+	private function updateMessageTemplate(string $template_field, array $message_template_fields): void
149
+	{
150
+		$MTP_ID = $message_template_fields['MTP_ID'] ?? 0;
151
+		// if we have a MTP_ID for this field then update it, otherwise insert.
152
+		// this has already been through the template field validator and sanitized, so it will be
153
+		// safe to insert this field.  Why insert?  This typically happens when we introduce a new
154
+		// message template field in a messenger/message type and existing users don't have the
155
+		// default setup for it.
156
+		// @link https://events.codebasehq.com/projects/event-espresso/tickets/9465
157
+		$updated = $MTP_ID
158
+			? $this->message_template_model->update($message_template_fields, [['MTP_ID' => $MTP_ID]])
159
+			: $this->message_template_model->insert($message_template_fields);
160
+
161
+		// updates will return 0 if the field was not changed (ie: no changes = nothing actually updated)
162
+		// but we won't consider that a problem, but if it returns false, then something went BOOM!
163
+		if ($updated === false) {
164
+			EE_Error::add_error(
165
+				sprintf(
166
+					esc_html__('%s field was NOT updated for some reason', 'event_espresso'),
167
+					$template_field
168
+				),
169
+				__FILE__,
170
+				__FUNCTION__,
171
+				__LINE__
172
+			);
173
+		}
174
+	}
175
+
176
+
177
+	/**
178
+	 * @param array $form_data
179
+	 * @return void
180
+	 * @throws EE_Error
181
+	 * @throws ReflectionException
182
+	 */
183
+	private function updateMessageTemplateGroup(array $form_data): void
184
+	{
185
+		try {
186
+			$GRP_ID = $form_data['id'] ?? 0;
187
+			$GRP_ID = $form_data['GRP_ID'] ?? $GRP_ID;
188
+			if (! $GRP_ID) {
189
+				throw new RuntimeException(
190
+					esc_html__(
191
+						'Can not update message template group because no GRP_ID was provided',
192
+						'event_espresso'
193
+					)
194
+				);
195
+			}
196
+
197
+			$updated       = $this->message_template_group_model->update($form_data, [['GRP_ID' => $GRP_ID]]);
198
+			$error_message = esc_html__(
199
+				'unknown error occurred while updating message template group',
200
+				'event_espresso'
201
+			);
202
+
203
+			if ($updated !== false) {
204
+				$message_template_group = $this->message_template_group_model->get_one_by_ID($GRP_ID);
205
+				if ($message_template_group instanceof EE_Message_Template_Group) {
206
+					// k now we need to ensure the template_pack and template_variation fields are set.
207
+					$template_pack      = $this->request->getRequestParam('MTP_template_pack', 'default');
208
+					$template_variation = $this->request->getRequestParam('MTP_template_variation', 'default');
209
+					$message_template_group->set_template_pack_name($template_pack);
210
+					$message_template_group->set_template_pack_variation($template_variation);
211
+				}
212
+				return;
213
+			}
214
+		} catch (RuntimeException $exception) {
215
+			$error_message = $exception->getMessage();
216
+		}
217
+
218
+		EE_Error::add_error(
219
+			sprintf(
220
+				esc_html__(
221
+					'The Message Template Group (%1$d) was NOT updated for the following reason: %2$s',
222
+					'event_espresso'
223
+				),
224
+				$form_data['GRP_ID'],
225
+				$error_message
226
+			),
227
+			__FILE__,
228
+			__FUNCTION__,
229
+			__LINE__
230
+		);
231
+	}
232
+
233
+
234
+	/**
235
+	 * recursively runs wp_kses() on message template content in a model safe manner
236
+	 *
237
+	 * @param array|string $content
238
+	 * @return array|string
239
+	 * @since   4.10.29.p
240
+	 */
241
+	private function sanitizeMessageTemplateContent($content)
242
+	{
243
+		if (is_array($content)) {
244
+			foreach ($content as $key => $value) {
245
+				$content[ $key ] = $this->sanitizeMessageTemplateContent($value);
246
+			}
247
+			return $content;
248
+		}
249
+		// remove slashes so wp_kses() works properly
250
+		// wp_kses_stripslashes() only removes slashes from double-quotes,
251
+		// so attributes using single quotes always appear invalid.
252
+		$content = stripslashes($content);
253
+		$content = wp_kses($content, wp_kses_allowed_html('post'));
254
+		// But currently the models expect slashed data, so after wp_kses()
255
+		// runs we need to re-slash the data. Sheesh.
256
+		// See https://events.codebasehq.com/projects/event-espresso/tickets/11211#update-47321587
257
+		return addslashes($content);
258
+	}
259
+
260
+
261
+	/**
262
+	 * @param int $GRP_ID
263
+	 * @return false|int
264
+	 * @throws EE_Error
265
+	 * @throws ReflectionException
266
+	 */
267
+	public function trashMessageTemplate(int $GRP_ID)
268
+	{
269
+		return $this->message_template_group_model->delete_by_ID($GRP_ID);
270
+	}
271
+
272
+
273
+	/**
274
+	 * @param int $GRP_ID
275
+	 * @return bool
276
+	 * @throws EE_Error
277
+	 */
278
+	public function restoreMessageTemplate(int $GRP_ID): bool
279
+	{
280
+		return $this->message_template_group_model->restore_by_ID($GRP_ID);
281
+	}
282
+
283
+
284
+	/**
285
+	 * @param int $GRP_ID
286
+	 * @return EE_Message_Template_Group
287
+	 * @throws EE_Error
288
+	 * @throws ReflectionException
289
+	 */
290
+	private function getMessageTemplateGroup(int $GRP_ID): EE_Message_Template_Group
291
+	{
292
+		$message_template_group = $this->message_template_group_model->get_one_by_ID($GRP_ID);
293
+		if ($message_template_group instanceof EE_Message_Template_Group) {
294
+			return $message_template_group;
295
+		}
296
+		throw new RuntimeException(
297
+			esc_html__(
298
+				'Can not permanently delete message template group because an invalid GRP_ID was provided',
299
+				'event_espresso'
300
+			)
301
+		);
302
+	}
303
+
304
+
305
+	/**
306
+	 * @param int $GRP_ID
307
+	 * @return bool
308
+	 * @throws EE_Error
309
+	 * @throws ReflectionException
310
+	 */
311
+	public function permanentlyDeleteMessageTemplates(int $GRP_ID): bool
312
+	{
313
+		$message_template_group = $this->getMessageTemplateGroup($GRP_ID);
314
+		// permanently delete all the related Message Templates
315
+		$deleted = $message_template_group->delete_related_permanently('Message_Template');
316
+		return $deleted > 0;
317
+	}
318
+
319
+
320
+	/**
321
+	 * @param int $GRP_ID
322
+	 * @return bool
323
+	 * @throws EE_Error
324
+	 * @throws ReflectionException
325
+	 */
326
+	public function permanentlyDeleteMessageTemplateGroup(int $GRP_ID): bool
327
+	{
328
+		if ($this->permanentlyDeleteMessageTemplates($GRP_ID)) {
329
+			return $this->message_template_group_model->delete_permanently([['GRP_ID' => $GRP_ID]]);
330
+		}
331
+		return false;
332
+	}
333
+
334
+
335
+	private function validateTemplateFieldData(string $template_field, array $data)
336
+	{
337
+		if (
338
+			! (
339
+				array_key_exists('MTP_ID', $data)
340
+				&& array_key_exists('name', $data)
341
+				&& array_key_exists('content', $data)
342
+			)
343
+		) {
344
+			throw new RuntimeException(
345
+				sprintf(
346
+					esc_html__(
347
+						'Can not update message template field %1$s because of a missing MTP_ID, name, or content.',
348
+						'event_espresso'
349
+					),
350
+					$template_field
351
+				)
352
+			);
353
+		}
354
+	}
355 355
 }
Please login to merge, or discard this patch.
core/domain/services/capabilities/FeatureFlagsConfig.php 2 patches
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -17,137 +17,137 @@
 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
-     * Whether to use the New Event Editor (EDTR) or continue using the legacy Event Editor
27
-     * deafult: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs
28
-     */
29
-    public const  USE_ADVANCED_EVENT_EDITOR = 'ee_advanced_event_editor';
30
-
31
-    /**
32
-     * Whether to enable the Bulk Edit feature in the Advanced Event Editor (EDTR)
33
-     * default: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs
34
-     */
35
-    public const  USE_EVENT_EDITOR_BULK_EDIT = 'ee_event_editor_bulk_edit';
36
-
37
-    /**
38
-     * Whether to enable the new Default Ticket Manager in the EDTR
39
-     * default: Enabled
40
-     */
41
-    public const  USE_DEFAULT_TICKET_MANAGER = 'use_default_ticket_manager';
42
-
43
-    /**
44
-     * Whether to enable the Rich Text Editor for the Event Description field in the EDTR or use tinymce
45
-     * default: Disabled
46
-     */
47
-    public const  USE_EVENT_DESCRIPTION_RTE = 'use_event_description_rte';
48
-
49
-    /**
50
-     * Whether to enable the Rich Text Editor for all other RTE fields in the EDTR
51
-     * default: Disabled
52
-     */
53
-    public const  USE_EXPERIMENTAL_RTE = 'use_experimental_rte';
54
-
55
-    /**
56
-     * Whether to enable the new Registration Form Builder in the EDTR
57
-     * or continue using the legacy Question Groups and Registration Form admin pages
58
-     * default: Disabled
59
-     */
60
-    public const  USE_REG_FORM_BUILDER = 'use_reg_form_builder';
61
-
62
-    /**
63
-     * Whether to enable the new Registration Options meta box in the EDTR
64
-     * or continue using the legacy Event Registration Options
65
-     * default: Disabled
66
-     */
67
-    public const  USE_REG_OPTIONS_META_BOX = 'use_reg_options_meta_box';
68
-
69
-
70
-    protected Domain $domain;
71
-
72
-
73
-    public function __construct(Domain $domain, JsonDataHandler $json_data_handler)
74
-    {
75
-        $this->domain = $domain;
76
-        parent::__construct($json_data_handler, FeatureFlagsConfig::OPTION_NAME, $this->getDefaultFeatureFlagOptions());
77
-    }
78
-
79
-
80
-    /**
81
-     * see the FeatureFlagsConfig::USE_* constants for descriptions of each feature flag and their default values
82
-     *
83
-     * @return stdClass
84
-     */
85
-    public function getDefaultFeatureFlagOptions(): stdClass
86
-    {
87
-        return (object) [
88
-            self::USE_ADVANCED_EVENT_EDITOR  => $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(),
89
-            self::USE_EVENT_EDITOR_BULK_EDIT => $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(),
90
-            self::USE_DEFAULT_TICKET_MANAGER => true,
91
-            self::USE_EVENT_DESCRIPTION_RTE  => false,
92
-            self::USE_EXPERIMENTAL_RTE       => false,
93
-            self::USE_REG_FORM_BUILDER       => false,
94
-            self::USE_REG_OPTIONS_META_BOX   => false,
95
-        ];
96
-    }
97
-
98
-
99
-    /**
100
-     * @return stdClass
101
-     */
102
-    public function getFeatureFlags(): stdClass
103
-    {
104
-        return $this->getAll() ?: $this->getDefaultFeatureFlagOptions();
105
-    }
106
-
107
-
108
-    public function saveFeatureFlagsConfig(stdClass $feature_flags): int
109
-    {
110
-        return $this->updateOption($feature_flags);
111
-    }
112
-
113
-
114
-    /**
115
-     * enables a feature flag, ex:
116
-     * $this->enableFeatureFlag(FeatureFlagsConfig::USE_ADVANCED_EVENT_EDITOR);
117
-     *
118
-     * @param string $feature_flag the feature flag to enable. One of the FeatureFlagsConfig::USE_* constants
119
-     * @return int
120
-     */
121
-    public function enableFeatureFlag(string $feature_flag): int
122
-    {
123
-        $feature_flags = $this->getFeatureFlags();
124
-        if (! property_exists($feature_flags, $feature_flag)) {
125
-            return WordPressOption::UPDATE_ERROR;
126
-        }
127
-        $feature_flags->{$feature_flag} = true;
128
-        // if feature flag is the advanced event editor or bulk edit options
129
-        // then only enabled if the site is Caffeinated and not MultiSite
130
-        if ($feature_flag === self::USE_ADVANCED_EVENT_EDITOR || $feature_flag === self::USE_EVENT_EDITOR_BULK_EDIT) {
131
-            $feature_flags->{$feature_flag} = $this->domain->isCaffeinated() && ! $this->domain->isMultiSite();
132
-        }
133
-        return $this->saveFeatureFlagsConfig($feature_flags);
134
-    }
135
-
136
-
137
-    /**
138
-     * disables a feature flag, ex:
139
-     * $this->disableFeatureFlag(FeatureFlagsConfig::USE_ADVANCED_EVENT_EDITOR);
140
-     *
141
-     * @param string $feature_flag the feature flag to disable. One of the FeatureFlagsConfig::USE_* constants
142
-     * @return int
143
-     */
144
-    public function disableFeatureFlag(string $feature_flag): int
145
-    {
146
-        $feature_flags = $this->getFeatureFlags();
147
-        if (! property_exists($feature_flags, $feature_flag)) {
148
-            return WordPressOption::UPDATE_ERROR;
149
-        }
150
-        $feature_flags->{$feature_flag} = false;
151
-        return $this->saveFeatureFlagsConfig($feature_flags);
152
-    }
20
+	/**
21
+	 * WP option name for saving the Feature Flags configuration
22
+	 */
23
+	private const OPTION_NAME = 'ee_feature_flags';
24
+
25
+	/**
26
+	 * Whether to use the New Event Editor (EDTR) or continue using the legacy Event Editor
27
+	 * deafult: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs
28
+	 */
29
+	public const  USE_ADVANCED_EVENT_EDITOR = 'ee_advanced_event_editor';
30
+
31
+	/**
32
+	 * Whether to enable the Bulk Edit feature in the Advanced Event Editor (EDTR)
33
+	 * default: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs
34
+	 */
35
+	public const  USE_EVENT_EDITOR_BULK_EDIT = 'ee_event_editor_bulk_edit';
36
+
37
+	/**
38
+	 * Whether to enable the new Default Ticket Manager in the EDTR
39
+	 * default: Enabled
40
+	 */
41
+	public const  USE_DEFAULT_TICKET_MANAGER = 'use_default_ticket_manager';
42
+
43
+	/**
44
+	 * Whether to enable the Rich Text Editor for the Event Description field in the EDTR or use tinymce
45
+	 * default: Disabled
46
+	 */
47
+	public const  USE_EVENT_DESCRIPTION_RTE = 'use_event_description_rte';
48
+
49
+	/**
50
+	 * Whether to enable the Rich Text Editor for all other RTE fields in the EDTR
51
+	 * default: Disabled
52
+	 */
53
+	public const  USE_EXPERIMENTAL_RTE = 'use_experimental_rte';
54
+
55
+	/**
56
+	 * Whether to enable the new Registration Form Builder in the EDTR
57
+	 * or continue using the legacy Question Groups and Registration Form admin pages
58
+	 * default: Disabled
59
+	 */
60
+	public const  USE_REG_FORM_BUILDER = 'use_reg_form_builder';
61
+
62
+	/**
63
+	 * Whether to enable the new Registration Options meta box in the EDTR
64
+	 * or continue using the legacy Event Registration Options
65
+	 * default: Disabled
66
+	 */
67
+	public const  USE_REG_OPTIONS_META_BOX = 'use_reg_options_meta_box';
68
+
69
+
70
+	protected Domain $domain;
71
+
72
+
73
+	public function __construct(Domain $domain, JsonDataHandler $json_data_handler)
74
+	{
75
+		$this->domain = $domain;
76
+		parent::__construct($json_data_handler, FeatureFlagsConfig::OPTION_NAME, $this->getDefaultFeatureFlagOptions());
77
+	}
78
+
79
+
80
+	/**
81
+	 * see the FeatureFlagsConfig::USE_* constants for descriptions of each feature flag and their default values
82
+	 *
83
+	 * @return stdClass
84
+	 */
85
+	public function getDefaultFeatureFlagOptions(): stdClass
86
+	{
87
+		return (object) [
88
+			self::USE_ADVANCED_EVENT_EDITOR  => $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(),
89
+			self::USE_EVENT_EDITOR_BULK_EDIT => $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(),
90
+			self::USE_DEFAULT_TICKET_MANAGER => true,
91
+			self::USE_EVENT_DESCRIPTION_RTE  => false,
92
+			self::USE_EXPERIMENTAL_RTE       => false,
93
+			self::USE_REG_FORM_BUILDER       => false,
94
+			self::USE_REG_OPTIONS_META_BOX   => false,
95
+		];
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return stdClass
101
+	 */
102
+	public function getFeatureFlags(): stdClass
103
+	{
104
+		return $this->getAll() ?: $this->getDefaultFeatureFlagOptions();
105
+	}
106
+
107
+
108
+	public function saveFeatureFlagsConfig(stdClass $feature_flags): int
109
+	{
110
+		return $this->updateOption($feature_flags);
111
+	}
112
+
113
+
114
+	/**
115
+	 * enables a feature flag, ex:
116
+	 * $this->enableFeatureFlag(FeatureFlagsConfig::USE_ADVANCED_EVENT_EDITOR);
117
+	 *
118
+	 * @param string $feature_flag the feature flag to enable. One of the FeatureFlagsConfig::USE_* constants
119
+	 * @return int
120
+	 */
121
+	public function enableFeatureFlag(string $feature_flag): int
122
+	{
123
+		$feature_flags = $this->getFeatureFlags();
124
+		if (! property_exists($feature_flags, $feature_flag)) {
125
+			return WordPressOption::UPDATE_ERROR;
126
+		}
127
+		$feature_flags->{$feature_flag} = true;
128
+		// if feature flag is the advanced event editor or bulk edit options
129
+		// then only enabled if the site is Caffeinated and not MultiSite
130
+		if ($feature_flag === self::USE_ADVANCED_EVENT_EDITOR || $feature_flag === self::USE_EVENT_EDITOR_BULK_EDIT) {
131
+			$feature_flags->{$feature_flag} = $this->domain->isCaffeinated() && ! $this->domain->isMultiSite();
132
+		}
133
+		return $this->saveFeatureFlagsConfig($feature_flags);
134
+	}
135
+
136
+
137
+	/**
138
+	 * disables a feature flag, ex:
139
+	 * $this->disableFeatureFlag(FeatureFlagsConfig::USE_ADVANCED_EVENT_EDITOR);
140
+	 *
141
+	 * @param string $feature_flag the feature flag to disable. One of the FeatureFlagsConfig::USE_* constants
142
+	 * @return int
143
+	 */
144
+	public function disableFeatureFlag(string $feature_flag): int
145
+	{
146
+		$feature_flags = $this->getFeatureFlags();
147
+		if (! property_exists($feature_flags, $feature_flag)) {
148
+			return WordPressOption::UPDATE_ERROR;
149
+		}
150
+		$feature_flags->{$feature_flag} = false;
151
+		return $this->saveFeatureFlagsConfig($feature_flags);
152
+	}
153 153
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     public function enableFeatureFlag(string $feature_flag): int
122 122
     {
123 123
         $feature_flags = $this->getFeatureFlags();
124
-        if (! property_exists($feature_flags, $feature_flag)) {
124
+        if ( ! property_exists($feature_flags, $feature_flag)) {
125 125
             return WordPressOption::UPDATE_ERROR;
126 126
         }
127 127
         $feature_flags->{$feature_flag} = true;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     public function disableFeatureFlag(string $feature_flag): int
145 145
     {
146 146
         $feature_flags = $this->getFeatureFlags();
147
-        if (! property_exists($feature_flags, $feature_flag)) {
147
+        if ( ! property_exists($feature_flags, $feature_flag)) {
148 148
             return WordPressOption::UPDATE_ERROR;
149 149
         }
150 150
         $feature_flags->{$feature_flag} = false;
Please login to merge, or discard this patch.
core/domain/services/capabilities/FeatureFlags.php 2 patches
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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
      */
73 73
     public function getAllowedFeatures(): array
74 74
     {
75
-        $allowed = array_filter( (array) $this->feature_flags, [$this, 'allowed'], ARRAY_FILTER_USE_KEY);
75
+        $allowed = array_filter((array) $this->feature_flags, [$this, 'allowed'], ARRAY_FILTER_USE_KEY);
76 76
         return array_keys($allowed);
77 77
     }
78 78
 }
Please login to merge, or discard this patch.
core/domain/services/assets/EspressoLegacyAdminAssetManager.php 2 patches
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -15,266 +15,266 @@
 block discarded – undo
15 15
 class EspressoLegacyAdminAssetManager extends AssetManager
16 16
 {
17 17
 
18
-    const JS_HANDLE_EE_ADMIN                = 'ee_admin_js';
18
+	const JS_HANDLE_EE_ADMIN                = 'ee_admin_js';
19 19
 
20
-    const JS_HANDLE_EE_AJAX_TABLE_SORTING   = 'espresso_ajax_table_sorting';
20
+	const JS_HANDLE_EE_AJAX_TABLE_SORTING   = 'espresso_ajax_table_sorting';
21 21
 
22
-    const JS_HANDLE_EE_DATEPICKER           = 'ee-datepicker';
22
+	const JS_HANDLE_EE_DATEPICKER           = 'ee-datepicker';
23 23
 
24
-    const JS_HANDLE_EE_DIALOG               = 'ee-dialog';
24
+	const JS_HANDLE_EE_DIALOG               = 'ee-dialog';
25 25
 
26
-    const JS_HANDLE_EE_HELP_TOUR            = 'ee-help-tour';
26
+	const JS_HANDLE_EE_HELP_TOUR            = 'ee-help-tour';
27 27
 
28
-    const JS_HANDLE_EE_INJECT_WP            = 'ee-inject-wp';
28
+	const JS_HANDLE_EE_INJECT_WP            = 'ee-inject-wp';
29 29
 
30
-    const JS_HANDLE_GOOGLE_CHARTS           = 'google-charts';
30
+	const JS_HANDLE_GOOGLE_CHARTS           = 'google-charts';
31 31
 
32
-    const JS_HANDLE_MOMENT                  = 'ee-moment';
32
+	const JS_HANDLE_MOMENT                  = 'ee-moment';
33 33
 
34
-    const JS_HANDLE_MOMENT_CORE             = 'ee-moment-core';
34
+	const JS_HANDLE_MOMENT_CORE             = 'ee-moment-core';
35 35
 
36
-    const JS_HANDLE_PARSE_URI               = 'ee-parse-uri';
36
+	const JS_HANDLE_PARSE_URI               = 'ee-parse-uri';
37 37
 
38
-    const JS_HANDLE_EE_TEXT_LINKS           = 'ee-text-links';
38
+	const JS_HANDLE_EE_TEXT_LINKS           = 'ee-text-links';
39 39
 
40
-    const JS_HANDLE_EE_SERIALIZE_FULL_ARRAY = 'ee-serialize-full-array';
40
+	const JS_HANDLE_EE_SERIALIZE_FULL_ARRAY = 'ee-serialize-full-array';
41 41
 
42
-    const JS_HANDLE_JOYRIDE_MODERNIZR       = 'joyride-modernizr';
42
+	const JS_HANDLE_JOYRIDE_MODERNIZR       = 'joyride-modernizr';
43 43
 
44
-    const JS_HANDLE_JQUERY_JOYRIDE          = 'jquery-joyride';
44
+	const JS_HANDLE_JQUERY_JOYRIDE          = 'jquery-joyride';
45 45
 
46
-    const CSS_HANDLE_EE_ADMIN               = 'ee-admin-css';
46
+	const CSS_HANDLE_EE_ADMIN               = 'ee-admin-css';
47 47
 
48
-    const CSS_HANDLE_EE_ADMIN_MEDIA_MODAL   = 'ee-admin-media-modal-css';
48
+	const CSS_HANDLE_EE_ADMIN_MEDIA_MODAL   = 'ee-admin-media-modal-css';
49 49
 
50
-    const CSS_HANDLE_EE_ADMIN_FILEBIRD      = 'ee-admin-filebird-css';
50
+	const CSS_HANDLE_EE_ADMIN_FILEBIRD      = 'ee-admin-filebird-css';
51 51
 
52
-    const CSS_HANDLE_EE_JOYRIDE             = 'ee-joyride-css';
52
+	const CSS_HANDLE_EE_JOYRIDE             = 'ee-joyride-css';
53 53
 
54
-    const CSS_HANDLE_EE_TEXT_LINKS          = 'ee-text-links';
54
+	const CSS_HANDLE_EE_TEXT_LINKS          = 'ee-text-links';
55 55
 
56
-    const CSS_HANDLE_EE_UI_THEME            = 'espresso-ui-theme';
57
-
58
-    const CSS_HANDLE_JOYRIDE                = 'joyride-css';
59
-
60
-
61
-    /**
62
-     * @inheritDoc
63
-     */
64
-    public function addAssets()
65
-    {
66
-        $joyride = filter_var(apply_filters('FHEE_load_joyride', false), FILTER_VALIDATE_BOOLEAN);
67
-        $this->registerJavascript($joyride);
68
-        $this->registerStyleSheets($joyride);
69
-    }
70
-
71
-
72
-    /**
73
-     * Register javascript assets
74
-     *
75
-     * @param bool $joyride
76
-     */
77
-    private function registerJavascript($joyride = false)
78
-    {
79
-        $this->addJavascript(
80
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_DIALOG,
81
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
82
-            [
83
-                JqueryAssetManager::JS_HANDLE_JQUERY,
84
-                JqueryAssetManager::JS_HANDLE_JQUERY_UI_DRAGGABLE,
85
-            ]
86
-        );
87
-        $this->addJavascript(
88
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
89
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
90
-            [
91
-                CoreAssetManager::JS_HANDLE_CORE,
92
-                EspressoLegacyAdminAssetManager::JS_HANDLE_PARSE_URI,
93
-                EspressoLegacyAdminAssetManager::JS_HANDLE_EE_DIALOG,
94
-            ]
95
-        );
96
-
97
-        // script for sorting tables
98
-        $this->addJavascript(
99
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_AJAX_TABLE_SORTING,
100
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
101
-            [
102
-                EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
103
-                JqueryAssetManager::JS_HANDLE_JQUERY_UI_SORTABLE,
104
-            ]
105
-        );
106
-
107
-        // script for parsing uri's
108
-        $this->addJavascript(
109
-            EspressoLegacyAdminAssetManager::JS_HANDLE_PARSE_URI,
110
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js'
111
-        );
112
-
113
-        // and parsing associative serialized form elements
114
-        $this->addJavascript(
115
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_SERIALIZE_FULL_ARRAY,
116
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
117
-            [JqueryAssetManager::JS_HANDLE_JQUERY]
118
-
119
-        );
120
-
121
-        // helpers scripts
122
-        $this->addJavascript(
123
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_TEXT_LINKS,
124
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
125
-            [JqueryAssetManager::JS_HANDLE_JQUERY]
126
-        );
127
-
128
-        $this->addJavascript(
129
-            EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT_CORE,
130
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js'
131
-        );
132
-
133
-        $this->addJavascript(
134
-            EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT,
135
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
136
-            [EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT_CORE]
137
-        );
138
-
139
-        $this->addJavascript(
140
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_DATEPICKER,
141
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
142
-            [
143
-                JqueryAssetManager::JS_HANDLE_JQUERY_UI_TIMEPICKER_ADDON,
144
-                EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT,
145
-            ]
146
-        );
147
-
148
-        // google charts
149
-        $this->addJavascript(
150
-            EspressoLegacyAdminAssetManager::JS_HANDLE_GOOGLE_CHARTS,
151
-            'https://www.gstatic.com/charts/loader.js'
152
-        );
153
-
154
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
155
-        // Note: the intention of this script is to only do TARGETED injections.
156
-        //ie: only injecting on certain script calls.
157
-        $this->addJavascript(
158
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_INJECT_WP,
159
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
160
-            [JqueryAssetManager::JS_HANDLE_JQUERY]
161
-        );
162
-
163
-        $this->loadQtipJs();
164
-
165
-        // joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook,
166
-        // can be turned back on again via: add_filter('FHEE_load_joyride', '__return_true' );
167
-        if (! $joyride) {
168
-            return;
169
-        }
170
-
171
-        $this->addJavascript(
172
-            EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR,
173
-            EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
174
-            [],
175
-            true,
176
-            '2.1'
177
-        );
178
-
179
-        // wanna go for a joyride?
180
-        $this->addJavascript(
181
-            EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_JOYRIDE,
182
-            EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
183
-            [
184
-                JqueryAssetManager::JS_HANDLE_JQUERY_COOKIE,
185
-                EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR,
186
-            ],
187
-            true,
188
-            '2.1'
189
-        )->setEnqueueImmediately();
190
-
191
-        $this->addJavascript(
192
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_HELP_TOUR,
193
-            EE_ADMIN_URL . 'assets/ee-help-tour.js',
194
-            [
195
-                EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_JOYRIDE,
196
-            ],
197
-            true,
198
-            '2.1'
199
-        )->setEnqueueImmediately();
200
-    }
201
-
202
-
203
-    /**
204
-     * Register CSS assets.
205
-     *
206
-     * @param bool $joyride
207
-     */
208
-    private function registerStyleSheets($joyride = false)
209
-    {
210
-
211
-        $this->addStylesheet(
212
-            EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_UI_THEME,
213
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css'
214
-        );
215
-
216
-        $this->addStylesheet(
217
-            EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_TEXT_LINKS,
218
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css'
219
-        );
220
-
221
-        $this->addStylesheet(
222
-            EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN,
223
-            EE_ADMIN_URL . 'assets/ee-admin-page.css',
224
-            ['espresso_admin_base']
225
-        )->setEnqueueImmediately();
226
-
227
-        if (
228
-            apply_filters(
229
-                'FHEE__EventEspresso_core_domain_services_assets_EspressoLegacyAdminAssetManager__registerStyleSheets__load_media_modal_css',
230
-                ! class_exists('FileBird\Plugin')
231
-            )
232
-        ) {
233
-            $this->addStylesheet(
234
-                EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN_MEDIA_MODAL,
235
-                EE_ADMIN_URL . 'assets/ee-admin-media-modal.css',
236
-                [EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN]
237
-            )->setEnqueueImmediately();
238
-        } else {
239
-            $this->addStylesheet(
240
-                EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN_FILEBIRD,
241
-                EE_ADMIN_URL . 'assets/ee-admin-media-modal-reset.css',
242
-                [EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN]
243
-            )->setEnqueueImmediately();
244
-        }
245
-
246
-        if (! $joyride) {
247
-            return;
248
-        }
249
-        // joyride style
250
-        $this->addStylesheet(
251
-            EspressoLegacyAdminAssetManager::CSS_HANDLE_JOYRIDE,
252
-            EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css',
253
-            [],
254
-            'all',
255
-            '2.1'
256
-        );
257
-
258
-        $this->addStylesheet(
259
-            EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_JOYRIDE,
260
-            EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
261
-            [EspressoLegacyAdminAssetManager::CSS_HANDLE_JOYRIDE]
262
-        )->setEnqueueImmediately();
263
-    }
264
-
265
-
266
-    /**
267
-     * registers assets for cleaning your ears
268
-     */
269
-    public function loadQtipJs()
270
-    {
271
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
272
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
273
-        if (apply_filters('FHEE_load_qtip', false)) {
274
-            $qtip_loader = EEH_Qtip_Loader::instance();
275
-            if ($qtip_loader instanceof EEH_Qtip_Loader) {
276
-                $qtip_loader->register_and_enqueue();
277
-            }
278
-        }
279
-    }
56
+	const CSS_HANDLE_EE_UI_THEME            = 'espresso-ui-theme';
57
+
58
+	const CSS_HANDLE_JOYRIDE                = 'joyride-css';
59
+
60
+
61
+	/**
62
+	 * @inheritDoc
63
+	 */
64
+	public function addAssets()
65
+	{
66
+		$joyride = filter_var(apply_filters('FHEE_load_joyride', false), FILTER_VALIDATE_BOOLEAN);
67
+		$this->registerJavascript($joyride);
68
+		$this->registerStyleSheets($joyride);
69
+	}
70
+
71
+
72
+	/**
73
+	 * Register javascript assets
74
+	 *
75
+	 * @param bool $joyride
76
+	 */
77
+	private function registerJavascript($joyride = false)
78
+	{
79
+		$this->addJavascript(
80
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_DIALOG,
81
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
82
+			[
83
+				JqueryAssetManager::JS_HANDLE_JQUERY,
84
+				JqueryAssetManager::JS_HANDLE_JQUERY_UI_DRAGGABLE,
85
+			]
86
+		);
87
+		$this->addJavascript(
88
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
89
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
90
+			[
91
+				CoreAssetManager::JS_HANDLE_CORE,
92
+				EspressoLegacyAdminAssetManager::JS_HANDLE_PARSE_URI,
93
+				EspressoLegacyAdminAssetManager::JS_HANDLE_EE_DIALOG,
94
+			]
95
+		);
96
+
97
+		// script for sorting tables
98
+		$this->addJavascript(
99
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_AJAX_TABLE_SORTING,
100
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
101
+			[
102
+				EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
103
+				JqueryAssetManager::JS_HANDLE_JQUERY_UI_SORTABLE,
104
+			]
105
+		);
106
+
107
+		// script for parsing uri's
108
+		$this->addJavascript(
109
+			EspressoLegacyAdminAssetManager::JS_HANDLE_PARSE_URI,
110
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js'
111
+		);
112
+
113
+		// and parsing associative serialized form elements
114
+		$this->addJavascript(
115
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_SERIALIZE_FULL_ARRAY,
116
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
117
+			[JqueryAssetManager::JS_HANDLE_JQUERY]
118
+
119
+		);
120
+
121
+		// helpers scripts
122
+		$this->addJavascript(
123
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_TEXT_LINKS,
124
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
125
+			[JqueryAssetManager::JS_HANDLE_JQUERY]
126
+		);
127
+
128
+		$this->addJavascript(
129
+			EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT_CORE,
130
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js'
131
+		);
132
+
133
+		$this->addJavascript(
134
+			EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT,
135
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
136
+			[EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT_CORE]
137
+		);
138
+
139
+		$this->addJavascript(
140
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_DATEPICKER,
141
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
142
+			[
143
+				JqueryAssetManager::JS_HANDLE_JQUERY_UI_TIMEPICKER_ADDON,
144
+				EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT,
145
+			]
146
+		);
147
+
148
+		// google charts
149
+		$this->addJavascript(
150
+			EspressoLegacyAdminAssetManager::JS_HANDLE_GOOGLE_CHARTS,
151
+			'https://www.gstatic.com/charts/loader.js'
152
+		);
153
+
154
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
155
+		// Note: the intention of this script is to only do TARGETED injections.
156
+		//ie: only injecting on certain script calls.
157
+		$this->addJavascript(
158
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_INJECT_WP,
159
+			EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
160
+			[JqueryAssetManager::JS_HANDLE_JQUERY]
161
+		);
162
+
163
+		$this->loadQtipJs();
164
+
165
+		// joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook,
166
+		// can be turned back on again via: add_filter('FHEE_load_joyride', '__return_true' );
167
+		if (! $joyride) {
168
+			return;
169
+		}
170
+
171
+		$this->addJavascript(
172
+			EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR,
173
+			EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
174
+			[],
175
+			true,
176
+			'2.1'
177
+		);
178
+
179
+		// wanna go for a joyride?
180
+		$this->addJavascript(
181
+			EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_JOYRIDE,
182
+			EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
183
+			[
184
+				JqueryAssetManager::JS_HANDLE_JQUERY_COOKIE,
185
+				EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR,
186
+			],
187
+			true,
188
+			'2.1'
189
+		)->setEnqueueImmediately();
190
+
191
+		$this->addJavascript(
192
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_HELP_TOUR,
193
+			EE_ADMIN_URL . 'assets/ee-help-tour.js',
194
+			[
195
+				EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_JOYRIDE,
196
+			],
197
+			true,
198
+			'2.1'
199
+		)->setEnqueueImmediately();
200
+	}
201
+
202
+
203
+	/**
204
+	 * Register CSS assets.
205
+	 *
206
+	 * @param bool $joyride
207
+	 */
208
+	private function registerStyleSheets($joyride = false)
209
+	{
210
+
211
+		$this->addStylesheet(
212
+			EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_UI_THEME,
213
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css'
214
+		);
215
+
216
+		$this->addStylesheet(
217
+			EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_TEXT_LINKS,
218
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css'
219
+		);
220
+
221
+		$this->addStylesheet(
222
+			EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN,
223
+			EE_ADMIN_URL . 'assets/ee-admin-page.css',
224
+			['espresso_admin_base']
225
+		)->setEnqueueImmediately();
226
+
227
+		if (
228
+			apply_filters(
229
+				'FHEE__EventEspresso_core_domain_services_assets_EspressoLegacyAdminAssetManager__registerStyleSheets__load_media_modal_css',
230
+				! class_exists('FileBird\Plugin')
231
+			)
232
+		) {
233
+			$this->addStylesheet(
234
+				EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN_MEDIA_MODAL,
235
+				EE_ADMIN_URL . 'assets/ee-admin-media-modal.css',
236
+				[EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN]
237
+			)->setEnqueueImmediately();
238
+		} else {
239
+			$this->addStylesheet(
240
+				EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN_FILEBIRD,
241
+				EE_ADMIN_URL . 'assets/ee-admin-media-modal-reset.css',
242
+				[EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN]
243
+			)->setEnqueueImmediately();
244
+		}
245
+
246
+		if (! $joyride) {
247
+			return;
248
+		}
249
+		// joyride style
250
+		$this->addStylesheet(
251
+			EspressoLegacyAdminAssetManager::CSS_HANDLE_JOYRIDE,
252
+			EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css',
253
+			[],
254
+			'all',
255
+			'2.1'
256
+		);
257
+
258
+		$this->addStylesheet(
259
+			EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_JOYRIDE,
260
+			EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
261
+			[EspressoLegacyAdminAssetManager::CSS_HANDLE_JOYRIDE]
262
+		)->setEnqueueImmediately();
263
+	}
264
+
265
+
266
+	/**
267
+	 * registers assets for cleaning your ears
268
+	 */
269
+	public function loadQtipJs()
270
+	{
271
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
272
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
273
+		if (apply_filters('FHEE_load_qtip', false)) {
274
+			$qtip_loader = EEH_Qtip_Loader::instance();
275
+			if ($qtip_loader instanceof EEH_Qtip_Loader) {
276
+				$qtip_loader->register_and_enqueue();
277
+			}
278
+		}
279
+	}
280 280
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     {
79 79
         $this->addJavascript(
80 80
             EspressoLegacyAdminAssetManager::JS_HANDLE_EE_DIALOG,
81
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
81
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
82 82
             [
83 83
                 JqueryAssetManager::JS_HANDLE_JQUERY,
84 84
                 JqueryAssetManager::JS_HANDLE_JQUERY_UI_DRAGGABLE,
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         );
87 87
         $this->addJavascript(
88 88
             EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
89
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
89
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
90 90
             [
91 91
                 CoreAssetManager::JS_HANDLE_CORE,
92 92
                 EspressoLegacyAdminAssetManager::JS_HANDLE_PARSE_URI,
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         // script for sorting tables
98 98
         $this->addJavascript(
99 99
             EspressoLegacyAdminAssetManager::JS_HANDLE_EE_AJAX_TABLE_SORTING,
100
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
100
+            EE_ADMIN_URL.'assets/espresso_ajax_table_sorting.js',
101 101
             [
102 102
                 EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
103 103
                 JqueryAssetManager::JS_HANDLE_JQUERY_UI_SORTABLE,
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
         // script for parsing uri's
108 108
         $this->addJavascript(
109 109
             EspressoLegacyAdminAssetManager::JS_HANDLE_PARSE_URI,
110
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js'
110
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js'
111 111
         );
112 112
 
113 113
         // and parsing associative serialized form elements
114 114
         $this->addJavascript(
115 115
             EspressoLegacyAdminAssetManager::JS_HANDLE_EE_SERIALIZE_FULL_ARRAY,
116
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
116
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
117 117
             [JqueryAssetManager::JS_HANDLE_JQUERY]
118 118
 
119 119
         );
@@ -121,24 +121,24 @@  discard block
 block discarded – undo
121 121
         // helpers scripts
122 122
         $this->addJavascript(
123 123
             EspressoLegacyAdminAssetManager::JS_HANDLE_EE_TEXT_LINKS,
124
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
124
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
125 125
             [JqueryAssetManager::JS_HANDLE_JQUERY]
126 126
         );
127 127
 
128 128
         $this->addJavascript(
129 129
             EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT_CORE,
130
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js'
130
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js'
131 131
         );
132 132
 
133 133
         $this->addJavascript(
134 134
             EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT,
135
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
135
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
136 136
             [EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT_CORE]
137 137
         );
138 138
 
139 139
         $this->addJavascript(
140 140
             EspressoLegacyAdminAssetManager::JS_HANDLE_EE_DATEPICKER,
141
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
141
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
142 142
             [
143 143
                 JqueryAssetManager::JS_HANDLE_JQUERY_UI_TIMEPICKER_ADDON,
144 144
                 EspressoLegacyAdminAssetManager::JS_HANDLE_MOMENT,
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         //ie: only injecting on certain script calls.
157 157
         $this->addJavascript(
158 158
             EspressoLegacyAdminAssetManager::JS_HANDLE_EE_INJECT_WP,
159
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
159
+            EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js',
160 160
             [JqueryAssetManager::JS_HANDLE_JQUERY]
161 161
         );
162 162
 
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 
165 165
         // joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook,
166 166
         // can be turned back on again via: add_filter('FHEE_load_joyride', '__return_true' );
167
-        if (! $joyride) {
167
+        if ( ! $joyride) {
168 168
             return;
169 169
         }
170 170
 
171 171
         $this->addJavascript(
172 172
             EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR,
173
-            EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
173
+            EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js',
174 174
             [],
175 175
             true,
176 176
             '2.1'
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         // wanna go for a joyride?
180 180
         $this->addJavascript(
181 181
             EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_JOYRIDE,
182
-            EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
182
+            EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js',
183 183
             [
184 184
                 JqueryAssetManager::JS_HANDLE_JQUERY_COOKIE,
185 185
                 EspressoLegacyAdminAssetManager::JS_HANDLE_JOYRIDE_MODERNIZR,
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
         $this->addJavascript(
192 192
             EspressoLegacyAdminAssetManager::JS_HANDLE_EE_HELP_TOUR,
193
-            EE_ADMIN_URL . 'assets/ee-help-tour.js',
193
+            EE_ADMIN_URL.'assets/ee-help-tour.js',
194 194
             [
195 195
                 EspressoLegacyAdminAssetManager::JS_HANDLE_JQUERY_JOYRIDE,
196 196
             ],
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
 
211 211
         $this->addStylesheet(
212 212
             EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_UI_THEME,
213
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css'
213
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css'
214 214
         );
215 215
 
216 216
         $this->addStylesheet(
217 217
             EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_TEXT_LINKS,
218
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css'
218
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css'
219 219
         );
220 220
 
221 221
         $this->addStylesheet(
222 222
             EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN,
223
-            EE_ADMIN_URL . 'assets/ee-admin-page.css',
223
+            EE_ADMIN_URL.'assets/ee-admin-page.css',
224 224
             ['espresso_admin_base']
225 225
         )->setEnqueueImmediately();
226 226
 
@@ -232,24 +232,24 @@  discard block
 block discarded – undo
232 232
         ) {
233 233
             $this->addStylesheet(
234 234
                 EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN_MEDIA_MODAL,
235
-                EE_ADMIN_URL . 'assets/ee-admin-media-modal.css',
235
+                EE_ADMIN_URL.'assets/ee-admin-media-modal.css',
236 236
                 [EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN]
237 237
             )->setEnqueueImmediately();
238 238
         } else {
239 239
             $this->addStylesheet(
240 240
                 EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN_FILEBIRD,
241
-                EE_ADMIN_URL . 'assets/ee-admin-media-modal-reset.css',
241
+                EE_ADMIN_URL.'assets/ee-admin-media-modal-reset.css',
242 242
                 [EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_ADMIN]
243 243
             )->setEnqueueImmediately();
244 244
         }
245 245
 
246
-        if (! $joyride) {
246
+        if ( ! $joyride) {
247 247
             return;
248 248
         }
249 249
         // joyride style
250 250
         $this->addStylesheet(
251 251
             EspressoLegacyAdminAssetManager::CSS_HANDLE_JOYRIDE,
252
-            EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css',
252
+            EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css',
253 253
             [],
254 254
             'all',
255 255
             '2.1'
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
         $this->addStylesheet(
259 259
             EspressoLegacyAdminAssetManager::CSS_HANDLE_EE_JOYRIDE,
260
-            EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
260
+            EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css',
261 261
             [EspressoLegacyAdminAssetManager::CSS_HANDLE_JOYRIDE]
262 262
         )->setEnqueueImmediately();
263 263
     }
Please login to merge, or discard this patch.
core/domain/entities/notifications/PersistentAdminNotice.php 2 patches
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -24,270 +24,270 @@
 block discarded – undo
24 24
  */
25 25
 class PersistentAdminNotice implements RequiresCapCheckInterface
26 26
 {
27
-    protected string $name = '';
28
-
29
-    protected string $message = '';
30
-
31
-    protected bool $force_update = false;
32
-
33
-    protected string $capability = 'manage_options';
34
-
35
-    protected string $cap_context = 'view persistent admin notice';
36
-
37
-    protected bool $dismissed = false;
38
-
39
-    protected ?CapCheckInterface $cap_check = null;
40
-
41
-    /**
42
-     * if true, then this notice will be deleted from the database
43
-     *
44
-     * @var boolean $purge
45
-     */
46
-    protected bool $purge = false;
47
-
48
-    /**
49
-     * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
50
-     * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
51
-     *
52
-     * @var boolean $registered
53
-     */
54
-    private bool $registered = false;
55
-
56
-
57
-    /**
58
-     * PersistentAdminNotice constructor
59
-     *
60
-     * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
61
-     * @param string $message      [required] the message to be stored persistently until dismissed
62
-     * @param bool   $force_update enforce the reappearance of a persistent message
63
-     * @param string $capability   user capability required to view this notice
64
-     * @param string $cap_context  description for why the cap check is being performed
65
-     * @param bool   $dismissed    whether the user has already dismissed/viewed this notice
66
-     */
67
-    public function __construct(
68
-        string $name,
69
-        string $message,
70
-        bool $force_update = false,
71
-        string $capability = 'manage_options',
72
-        string $cap_context = 'view persistent admin notice',
73
-        bool $dismissed = false
74
-    ) {
75
-        $this->setName($name);
76
-        $this->setMessage($message);
77
-        $this->setForceUpdate($force_update);
78
-        $this->setCapability($capability);
79
-        $this->setCapContext($cap_context);
80
-        $this->setDismissed($dismissed);
81
-        add_action(
82
-            'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
83
-            [$this, 'registerPersistentAdminNotice']
84
-        );
85
-        add_action('shutdown', [$this, 'confirmRegistered'], 999);
86
-    }
87
-
88
-
89
-    /**
90
-     * @return string
91
-     */
92
-    public function getName(): string
93
-    {
94
-        return $this->name;
95
-    }
96
-
97
-
98
-    /**
99
-     * @param string $name
100
-     */
101
-    private function setName(string $name)
102
-    {
103
-        $this->name = sanitize_key($name);
104
-    }
105
-
106
-
107
-    /**
108
-     * @return string
109
-     */
110
-    public function getMessage(): string
111
-    {
112
-        return $this->message;
113
-    }
114
-
115
-
116
-    /**
117
-     * @param string $message
118
-     */
119
-    private function setMessage(string $message)
120
-    {
121
-        $allowedtags   = AllowedTags::getAllowedTags();
122
-        $this->message = wp_kses($message, $allowedtags);
123
-    }
124
-
125
-
126
-    /**
127
-     * @return bool
128
-     */
129
-    public function getForceUpdate(): bool
130
-    {
131
-        return $this->force_update;
132
-    }
133
-
134
-
135
-    /**
136
-     * @param bool|int|string $force_update
137
-     */
138
-    private function setForceUpdate($force_update)
139
-    {
140
-        $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
141
-    }
142
-
143
-
144
-    /**
145
-     * @return string
146
-     */
147
-    public function getCapability(): string
148
-    {
149
-        return $this->capability;
150
-    }
151
-
152
-
153
-    /**
154
-     * @param string $capability
155
-     */
156
-    private function setCapability(string $capability)
157
-    {
158
-        $this->capability = ! empty($capability) ? $capability : 'manage_options';
159
-    }
160
-
161
-
162
-    /**
163
-     * @return string
164
-     */
165
-    public function getCapContext(): string
166
-    {
167
-        return $this->cap_context;
168
-    }
169
-
170
-
171
-    /**
172
-     * @param string $cap_context
173
-     */
174
-    private function setCapContext(string $cap_context)
175
-    {
176
-        $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
177
-    }
178
-
179
-
180
-    /**
181
-     * @return bool
182
-     */
183
-    public function getDismissed(): bool
184
-    {
185
-        return $this->dismissed;
186
-    }
187
-
188
-
189
-    /**
190
-     * @param bool|int|string $dismissed
191
-     */
192
-    public function setDismissed($dismissed)
193
-    {
194
-        $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
195
-    }
196
-
197
-
198
-    /**
199
-     * @return CapCheckInterface
200
-     */
201
-    public function getCapCheck(): ?CapCheckInterface
202
-    {
203
-        if (! $this->cap_check instanceof CapCheckInterface) {
204
-            $this->setCapCheck(new CapCheck($this->capability, $this->cap_context));
205
-        }
206
-        return $this->cap_check;
207
-    }
208
-
209
-
210
-    /**
211
-     * @param CapCheckInterface $cap_check
212
-     */
213
-    private function setCapCheck(CapCheckInterface $cap_check)
214
-    {
215
-        $this->cap_check = $cap_check;
216
-    }
217
-
218
-
219
-    /**
220
-     * @return bool
221
-     */
222
-    public function getPurge(): bool
223
-    {
224
-        return $this->purge;
225
-    }
226
-
227
-
228
-    /**
229
-     * @param bool|int|string $purge
230
-     */
231
-    public function setPurge($purge)
232
-    {
233
-        $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
234
-    }
235
-
236
-
237
-    /**
238
-     * given a valid PersistentAdminNotice Collection,
239
-     * this notice will be added if it is not already found in the collection (using its name as the identifier)
240
-     * if an existing notice is found that has already been dismissed,
241
-     * but we are overriding with a forced update, then we will toggle its dismissed state,
242
-     * so that the notice is displayed again
243
-     *
244
-     * @param Collection $persistent_admin_notice_collection
245
-     * @throws InvalidEntityException
246
-     * @throws DuplicateCollectionIdentifierException
247
-     */
248
-    public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
249
-    {
250
-        if ($this->registered) {
251
-            return;
252
-        }
253
-        // first check if this notice has already been added to the collection
254
-        if ($persistent_admin_notice_collection->has($this->name)) {
255
-            /** @var PersistentAdminNotice $existing */
256
-            $existing = $persistent_admin_notice_collection->get($this->name);
257
-            // we don't need to add it again (we can't actually)
258
-            // but if it has already been dismissed, and we are overriding with a forced update
259
-            if ($existing->getDismissed() && $this->getForceUpdate()) {
260
-                // then toggle the notice's dismissed state to true
261
-                // so that it gets displayed again
262
-                $existing->setDismissed(false);
263
-                // and make sure the message is set
264
-                $existing->setMessage($this->message);
265
-            }
266
-        } else {
267
-            $persistent_admin_notice_collection->add($this, $this->name);
268
-        }
269
-        $this->registered = true;
270
-    }
271
-
272
-
273
-    /**
274
-     * @throws Exception
275
-     */
276
-    public function confirmRegistered()
277
-    {
278
-        if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
279
-            PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
280
-        }
281
-        if (! $this->registered && WP_DEBUG) {
282
-            throw new DomainException(
283
-                sprintf(
284
-                    esc_html__(
285
-                        'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.',
286
-                        'event_espresso'
287
-                    ),
288
-                    $this->name
289
-                )
290
-            );
291
-        }
292
-    }
27
+	protected string $name = '';
28
+
29
+	protected string $message = '';
30
+
31
+	protected bool $force_update = false;
32
+
33
+	protected string $capability = 'manage_options';
34
+
35
+	protected string $cap_context = 'view persistent admin notice';
36
+
37
+	protected bool $dismissed = false;
38
+
39
+	protected ?CapCheckInterface $cap_check = null;
40
+
41
+	/**
42
+	 * if true, then this notice will be deleted from the database
43
+	 *
44
+	 * @var boolean $purge
45
+	 */
46
+	protected bool $purge = false;
47
+
48
+	/**
49
+	 * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
50
+	 * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
51
+	 *
52
+	 * @var boolean $registered
53
+	 */
54
+	private bool $registered = false;
55
+
56
+
57
+	/**
58
+	 * PersistentAdminNotice constructor
59
+	 *
60
+	 * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
61
+	 * @param string $message      [required] the message to be stored persistently until dismissed
62
+	 * @param bool   $force_update enforce the reappearance of a persistent message
63
+	 * @param string $capability   user capability required to view this notice
64
+	 * @param string $cap_context  description for why the cap check is being performed
65
+	 * @param bool   $dismissed    whether the user has already dismissed/viewed this notice
66
+	 */
67
+	public function __construct(
68
+		string $name,
69
+		string $message,
70
+		bool $force_update = false,
71
+		string $capability = 'manage_options',
72
+		string $cap_context = 'view persistent admin notice',
73
+		bool $dismissed = false
74
+	) {
75
+		$this->setName($name);
76
+		$this->setMessage($message);
77
+		$this->setForceUpdate($force_update);
78
+		$this->setCapability($capability);
79
+		$this->setCapContext($cap_context);
80
+		$this->setDismissed($dismissed);
81
+		add_action(
82
+			'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
83
+			[$this, 'registerPersistentAdminNotice']
84
+		);
85
+		add_action('shutdown', [$this, 'confirmRegistered'], 999);
86
+	}
87
+
88
+
89
+	/**
90
+	 * @return string
91
+	 */
92
+	public function getName(): string
93
+	{
94
+		return $this->name;
95
+	}
96
+
97
+
98
+	/**
99
+	 * @param string $name
100
+	 */
101
+	private function setName(string $name)
102
+	{
103
+		$this->name = sanitize_key($name);
104
+	}
105
+
106
+
107
+	/**
108
+	 * @return string
109
+	 */
110
+	public function getMessage(): string
111
+	{
112
+		return $this->message;
113
+	}
114
+
115
+
116
+	/**
117
+	 * @param string $message
118
+	 */
119
+	private function setMessage(string $message)
120
+	{
121
+		$allowedtags   = AllowedTags::getAllowedTags();
122
+		$this->message = wp_kses($message, $allowedtags);
123
+	}
124
+
125
+
126
+	/**
127
+	 * @return bool
128
+	 */
129
+	public function getForceUpdate(): bool
130
+	{
131
+		return $this->force_update;
132
+	}
133
+
134
+
135
+	/**
136
+	 * @param bool|int|string $force_update
137
+	 */
138
+	private function setForceUpdate($force_update)
139
+	{
140
+		$this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
141
+	}
142
+
143
+
144
+	/**
145
+	 * @return string
146
+	 */
147
+	public function getCapability(): string
148
+	{
149
+		return $this->capability;
150
+	}
151
+
152
+
153
+	/**
154
+	 * @param string $capability
155
+	 */
156
+	private function setCapability(string $capability)
157
+	{
158
+		$this->capability = ! empty($capability) ? $capability : 'manage_options';
159
+	}
160
+
161
+
162
+	/**
163
+	 * @return string
164
+	 */
165
+	public function getCapContext(): string
166
+	{
167
+		return $this->cap_context;
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param string $cap_context
173
+	 */
174
+	private function setCapContext(string $cap_context)
175
+	{
176
+		$this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
177
+	}
178
+
179
+
180
+	/**
181
+	 * @return bool
182
+	 */
183
+	public function getDismissed(): bool
184
+	{
185
+		return $this->dismissed;
186
+	}
187
+
188
+
189
+	/**
190
+	 * @param bool|int|string $dismissed
191
+	 */
192
+	public function setDismissed($dismissed)
193
+	{
194
+		$this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
195
+	}
196
+
197
+
198
+	/**
199
+	 * @return CapCheckInterface
200
+	 */
201
+	public function getCapCheck(): ?CapCheckInterface
202
+	{
203
+		if (! $this->cap_check instanceof CapCheckInterface) {
204
+			$this->setCapCheck(new CapCheck($this->capability, $this->cap_context));
205
+		}
206
+		return $this->cap_check;
207
+	}
208
+
209
+
210
+	/**
211
+	 * @param CapCheckInterface $cap_check
212
+	 */
213
+	private function setCapCheck(CapCheckInterface $cap_check)
214
+	{
215
+		$this->cap_check = $cap_check;
216
+	}
217
+
218
+
219
+	/**
220
+	 * @return bool
221
+	 */
222
+	public function getPurge(): bool
223
+	{
224
+		return $this->purge;
225
+	}
226
+
227
+
228
+	/**
229
+	 * @param bool|int|string $purge
230
+	 */
231
+	public function setPurge($purge)
232
+	{
233
+		$this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
234
+	}
235
+
236
+
237
+	/**
238
+	 * given a valid PersistentAdminNotice Collection,
239
+	 * this notice will be added if it is not already found in the collection (using its name as the identifier)
240
+	 * if an existing notice is found that has already been dismissed,
241
+	 * but we are overriding with a forced update, then we will toggle its dismissed state,
242
+	 * so that the notice is displayed again
243
+	 *
244
+	 * @param Collection $persistent_admin_notice_collection
245
+	 * @throws InvalidEntityException
246
+	 * @throws DuplicateCollectionIdentifierException
247
+	 */
248
+	public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
249
+	{
250
+		if ($this->registered) {
251
+			return;
252
+		}
253
+		// first check if this notice has already been added to the collection
254
+		if ($persistent_admin_notice_collection->has($this->name)) {
255
+			/** @var PersistentAdminNotice $existing */
256
+			$existing = $persistent_admin_notice_collection->get($this->name);
257
+			// we don't need to add it again (we can't actually)
258
+			// but if it has already been dismissed, and we are overriding with a forced update
259
+			if ($existing->getDismissed() && $this->getForceUpdate()) {
260
+				// then toggle the notice's dismissed state to true
261
+				// so that it gets displayed again
262
+				$existing->setDismissed(false);
263
+				// and make sure the message is set
264
+				$existing->setMessage($this->message);
265
+			}
266
+		} else {
267
+			$persistent_admin_notice_collection->add($this, $this->name);
268
+		}
269
+		$this->registered = true;
270
+	}
271
+
272
+
273
+	/**
274
+	 * @throws Exception
275
+	 */
276
+	public function confirmRegistered()
277
+	{
278
+		if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
279
+			PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
280
+		}
281
+		if (! $this->registered && WP_DEBUG) {
282
+			throw new DomainException(
283
+				sprintf(
284
+					esc_html__(
285
+						'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.',
286
+						'event_espresso'
287
+					),
288
+					$this->name
289
+				)
290
+			);
291
+		}
292
+	}
293 293
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      */
201 201
     public function getCapCheck(): ?CapCheckInterface
202 202
     {
203
-        if (! $this->cap_check instanceof CapCheckInterface) {
203
+        if ( ! $this->cap_check instanceof CapCheckInterface) {
204 204
             $this->setCapCheck(new CapCheck($this->capability, $this->cap_context));
205 205
         }
206 206
         return $this->cap_check;
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
      */
276 276
     public function confirmRegistered()
277 277
     {
278
-        if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
278
+        if ( ! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
279 279
             PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
280 280
         }
281
-        if (! $this->registered && WP_DEBUG) {
281
+        if ( ! $this->registered && WP_DEBUG) {
282 282
             throw new DomainException(
283 283
                 sprintf(
284 284
                     esc_html__(
Please login to merge, or discard this patch.
core/services/request/sanitizers/AllowedTags.php 1 patch
Indentation   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -12,298 +12,298 @@
 block discarded – undo
12 12
  */
13 13
 class AllowedTags
14 14
 {
15
-    /**
16
-     * @var array[]
17
-     */
18
-    private static $attributes = [
19
-        'accept-charset'    => true,
20
-        'action'            => true,
21
-        'alt'               => true,
22
-        'allow'             => true,
23
-        'allowfullscreen'   => true,
24
-        'align'             => true,
25
-        'aria-controls'     => true,
26
-        'aria-current'      => true,
27
-        'aria-describedby'  => true,
28
-        'aria-details'      => true,
29
-        'aria-expanded'     => true,
30
-        'aria-hidden'       => true,
31
-        'aria-label'        => true,
32
-        'aria-labelledby'   => true,
33
-        'aria-live'         => true,
34
-        'autocomplete'      => true,
35
-        'bgcolor'           => true,
36
-        'border'            => true,
37
-        'cellpadding'       => true,
38
-        'cellspacing'       => true,
39
-        'checked'           => true,
40
-        'class'             => true,
41
-        'cols'              => true,
42
-        'content'           => true,
43
-        'data-*'            => true,
44
-        'dir'               => true,
45
-        'disabled'          => true,
46
-        'enctype'           => true,
47
-        'extension'         => true,
48
-        'for'               => true,
49
-        'frameborder'       => true,
50
-        'height'            => true,
51
-        'href'              => true,
52
-        'id'                => true,
53
-        'itemprop'          => true,
54
-        'itemscope'         => true,
55
-        'itemtype'          => true,
56
-        'label'             => true,
57
-        'lang'              => true,
58
-        'leftmargin'        => true,
59
-        'marginheight'      => true,
60
-        'marginwidth'       => true,
61
-        'max'               => true,
62
-        'maxlength'         => true,
63
-        'media'             => true,
64
-        'method'            => true,
65
-        'min'               => true,
66
-        'multiple'          => true,
67
-        'name'              => true,
68
-        'novalidate'        => true,
69
-        'onclick'           => true,
70
-        'placeholder'       => true,
71
-        'property'          => true,
72
-        'readonly'          => true,
73
-        'rel'               => true,
74
-        'required'          => true,
75
-        'rows'              => true,
76
-        'selected'          => true,
77
-        'src'               => true,
78
-        'size'              => true,
79
-        'style'             => true,
80
-        'step'              => true,
81
-        'tabindex'          => true,
82
-        'target'            => true,
83
-        'title'             => true,
84
-        'topmargin'         => true,
85
-        'type'              => true,
86
-        'value'             => true,
87
-        'width'             => true,
88
-        'http-equiv'        => true,
89
-    ];
90
-
91
-
92
-    /**
93
-     * @var array
94
-     */
95
-    private static $tags = [
96
-        'a',
97
-        'abbr',
98
-        'b',
99
-        'br',
100
-        'code',
101
-        'div',
102
-        'em',
103
-        'h1',
104
-        'h2',
105
-        'h3',
106
-        'h4',
107
-        'h5',
108
-        'h6',
109
-        'hr',
110
-        'i',
111
-        'img',
112
-        'li',
113
-        'ol',
114
-        'p',
115
-        'pre',
116
-        'small',
117
-        'span',
118
-        'strong',
119
-        'table',
120
-        'td',
121
-        'tr',
122
-        'ul',
123
-    ];
124
-
125
-
126
-    /**
127
-     * @var array
128
-     */
129
-    private static $allowed_tags;
130
-
131
-
132
-    /**
133
-     * @var array
134
-     */
135
-    private static $allowed_with_embed_tags;
136
-
137
-
138
-    /**
139
-     * @var array
140
-     */
141
-    private static $allowed_with_form_tags;
142
-
143
-
144
-    /**
145
-     * @var array
146
-     */
147
-    private static $allowed_with_script_and_style_tags;
148
-
149
-    /**
150
-     * @var array
151
-     */
152
-    private static $allowed_with_full_tags;
153
-
154
-
155
-    /**
156
-     * merges additional tags and attributes into the WP post tags
157
-     */
158
-    private static function initializeAllowedTags()
159
-    {
160
-        $allowed_post_tags = wp_kses_allowed_html('post');
161
-        $allowed_tags = [];
162
-        foreach (AllowedTags::$tags as $tag) {
163
-            $allowed_tags[ $tag ] = AllowedTags::$attributes;
164
-        }
165
-        AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags);
166
-    }
167
-
168
-
169
-    /**
170
-     * merges embed tags and attributes into the EE all tags
171
-     */
172
-    private static function initializeWithEmbedTags()
173
-    {
174
-        $all_tags = AllowedTags::getAllowedTags();
175
-        $embed_tags = [
176
-            'iframe' => AllowedTags::$attributes
177
-        ];
178
-        AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags);
179
-    }
180
-
181
-
182
-    /**
183
-     * merges form tags and attributes into the EE all tags
184
-     */
185
-    private static function initializeWithFormTags()
186
-    {
187
-        $all_tags = AllowedTags::getAllowedTags();
188
-        $form_tags = [
189
-            'form'     => AllowedTags::$attributes,
190
-            'label'    => AllowedTags::$attributes,
191
-            'input'    => AllowedTags::$attributes,
192
-            'select'   => AllowedTags::$attributes,
193
-            'option'   => AllowedTags::$attributes,
194
-            'optgroup' => AllowedTags::$attributes,
195
-            'textarea' => AllowedTags::$attributes,
196
-            'button'   => AllowedTags::$attributes,
197
-            'fieldset' => AllowedTags::$attributes,
198
-            'output'   => AllowedTags::$attributes,
199
-        ];
200
-        AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags);
201
-    }
202
-
203
-
204
-    /**
205
-     * merges form script and style tags and attributes into the EE all tags
206
-     */
207
-    private static function initializeWithScriptAndStyleTags()
208
-    {
209
-        $all_tags = AllowedTags::getAllowedTags();
210
-        $script_and_style_tags = [
211
-            'script'   => AllowedTags::$attributes,
212
-            'style'    => AllowedTags::$attributes,
213
-            'link'     => AllowedTags::$attributes,
214
-            'noscript' => AllowedTags::$attributes,
215
-        ];
216
-        AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags);
217
-    }
218
-
219
-    /**
220
-     * merges all head and body tags and attributes into the EE all tags
221
-     */
222
-    private static function initializeWithFullTags()
223
-    {
224
-        $all_tags = AllowedTags::getAllowedTags();
225
-        $full_tags = [
226
-            'script'    => AllowedTags::$attributes,
227
-            'style'     => AllowedTags::$attributes,
228
-            'link'      => AllowedTags::$attributes,
229
-            'title'     => AllowedTags::$attributes,
230
-            'meta'      => AllowedTags::$attributes,
231
-            'iframe'    => AllowedTags::$attributes,
232
-            'form'      => AllowedTags::$attributes,
233
-            'label'     => AllowedTags::$attributes,
234
-            'input'     => AllowedTags::$attributes,
235
-            'select'    => AllowedTags::$attributes,
236
-            'option'    => AllowedTags::$attributes,
237
-            'optgroup'  => AllowedTags::$attributes,
238
-            'textarea'  => AllowedTags::$attributes,
239
-            'button'    => AllowedTags::$attributes,
240
-            'fieldset'  => AllowedTags::$attributes,
241
-            'output'    => AllowedTags::$attributes,
242
-            'noscript'  => AllowedTags::$attributes,
243
-            'html'      => AllowedTags::$attributes,
244
-            'body'      => AllowedTags::$attributes,
245
-            'head'      => AllowedTags::$attributes,
246
-        ];
247
-        AllowedTags::$allowed_with_full_tags = array_merge_recursive($all_tags, $full_tags);
248
-    }
249
-
250
-
251
-    /**
252
-     * @return array[]
253
-     */
254
-    public static function getAllowedTags()
255
-    {
256
-        if (empty(AllowedTags::$allowed_tags)) {
257
-            AllowedTags::initializeAllowedTags();
258
-        }
259
-        return AllowedTags::$allowed_tags;
260
-    }
261
-
262
-
263
-    /**
264
-     * @return array[]
265
-     */
266
-    public static function getWithEmbedTags()
267
-    {
268
-        if (empty(AllowedTags::$allowed_with_embed_tags)) {
269
-            AllowedTags::initializeWithEmbedTags();
270
-        }
271
-        return AllowedTags::$allowed_with_embed_tags;
272
-    }
273
-
274
-
275
-    /**
276
-     * @return array[]
277
-     */
278
-    public static function getWithFormTags()
279
-    {
280
-        if (empty(AllowedTags::$allowed_with_form_tags)) {
281
-            AllowedTags::initializeWithFormTags();
282
-        }
283
-        return AllowedTags::$allowed_with_form_tags;
284
-    }
285
-
286
-
287
-    /**
288
-     * @return array[]
289
-     */
290
-    public static function getWithScriptAndStyleTags()
291
-    {
292
-        if (empty(AllowedTags::$allowed_with_script_and_style_tags)) {
293
-            AllowedTags::initializeWithScriptAndStyleTags();
294
-        }
295
-        return AllowedTags::$allowed_with_script_and_style_tags;
296
-    }
297
-
298
-
299
-    /**
300
-     * @return array[]
301
-     */
302
-    public static function getWithFullTags()
303
-    {
304
-        if (empty(AllowedTags::$allowed_with_full_tags)) {
305
-            AllowedTags::initializeWithFullTags();
306
-        }
307
-        return AllowedTags::$allowed_with_full_tags;
308
-    }
15
+	/**
16
+	 * @var array[]
17
+	 */
18
+	private static $attributes = [
19
+		'accept-charset'    => true,
20
+		'action'            => true,
21
+		'alt'               => true,
22
+		'allow'             => true,
23
+		'allowfullscreen'   => true,
24
+		'align'             => true,
25
+		'aria-controls'     => true,
26
+		'aria-current'      => true,
27
+		'aria-describedby'  => true,
28
+		'aria-details'      => true,
29
+		'aria-expanded'     => true,
30
+		'aria-hidden'       => true,
31
+		'aria-label'        => true,
32
+		'aria-labelledby'   => true,
33
+		'aria-live'         => true,
34
+		'autocomplete'      => true,
35
+		'bgcolor'           => true,
36
+		'border'            => true,
37
+		'cellpadding'       => true,
38
+		'cellspacing'       => true,
39
+		'checked'           => true,
40
+		'class'             => true,
41
+		'cols'              => true,
42
+		'content'           => true,
43
+		'data-*'            => true,
44
+		'dir'               => true,
45
+		'disabled'          => true,
46
+		'enctype'           => true,
47
+		'extension'         => true,
48
+		'for'               => true,
49
+		'frameborder'       => true,
50
+		'height'            => true,
51
+		'href'              => true,
52
+		'id'                => true,
53
+		'itemprop'          => true,
54
+		'itemscope'         => true,
55
+		'itemtype'          => true,
56
+		'label'             => true,
57
+		'lang'              => true,
58
+		'leftmargin'        => true,
59
+		'marginheight'      => true,
60
+		'marginwidth'       => true,
61
+		'max'               => true,
62
+		'maxlength'         => true,
63
+		'media'             => true,
64
+		'method'            => true,
65
+		'min'               => true,
66
+		'multiple'          => true,
67
+		'name'              => true,
68
+		'novalidate'        => true,
69
+		'onclick'           => true,
70
+		'placeholder'       => true,
71
+		'property'          => true,
72
+		'readonly'          => true,
73
+		'rel'               => true,
74
+		'required'          => true,
75
+		'rows'              => true,
76
+		'selected'          => true,
77
+		'src'               => true,
78
+		'size'              => true,
79
+		'style'             => true,
80
+		'step'              => true,
81
+		'tabindex'          => true,
82
+		'target'            => true,
83
+		'title'             => true,
84
+		'topmargin'         => true,
85
+		'type'              => true,
86
+		'value'             => true,
87
+		'width'             => true,
88
+		'http-equiv'        => true,
89
+	];
90
+
91
+
92
+	/**
93
+	 * @var array
94
+	 */
95
+	private static $tags = [
96
+		'a',
97
+		'abbr',
98
+		'b',
99
+		'br',
100
+		'code',
101
+		'div',
102
+		'em',
103
+		'h1',
104
+		'h2',
105
+		'h3',
106
+		'h4',
107
+		'h5',
108
+		'h6',
109
+		'hr',
110
+		'i',
111
+		'img',
112
+		'li',
113
+		'ol',
114
+		'p',
115
+		'pre',
116
+		'small',
117
+		'span',
118
+		'strong',
119
+		'table',
120
+		'td',
121
+		'tr',
122
+		'ul',
123
+	];
124
+
125
+
126
+	/**
127
+	 * @var array
128
+	 */
129
+	private static $allowed_tags;
130
+
131
+
132
+	/**
133
+	 * @var array
134
+	 */
135
+	private static $allowed_with_embed_tags;
136
+
137
+
138
+	/**
139
+	 * @var array
140
+	 */
141
+	private static $allowed_with_form_tags;
142
+
143
+
144
+	/**
145
+	 * @var array
146
+	 */
147
+	private static $allowed_with_script_and_style_tags;
148
+
149
+	/**
150
+	 * @var array
151
+	 */
152
+	private static $allowed_with_full_tags;
153
+
154
+
155
+	/**
156
+	 * merges additional tags and attributes into the WP post tags
157
+	 */
158
+	private static function initializeAllowedTags()
159
+	{
160
+		$allowed_post_tags = wp_kses_allowed_html('post');
161
+		$allowed_tags = [];
162
+		foreach (AllowedTags::$tags as $tag) {
163
+			$allowed_tags[ $tag ] = AllowedTags::$attributes;
164
+		}
165
+		AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags);
166
+	}
167
+
168
+
169
+	/**
170
+	 * merges embed tags and attributes into the EE all tags
171
+	 */
172
+	private static function initializeWithEmbedTags()
173
+	{
174
+		$all_tags = AllowedTags::getAllowedTags();
175
+		$embed_tags = [
176
+			'iframe' => AllowedTags::$attributes
177
+		];
178
+		AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags);
179
+	}
180
+
181
+
182
+	/**
183
+	 * merges form tags and attributes into the EE all tags
184
+	 */
185
+	private static function initializeWithFormTags()
186
+	{
187
+		$all_tags = AllowedTags::getAllowedTags();
188
+		$form_tags = [
189
+			'form'     => AllowedTags::$attributes,
190
+			'label'    => AllowedTags::$attributes,
191
+			'input'    => AllowedTags::$attributes,
192
+			'select'   => AllowedTags::$attributes,
193
+			'option'   => AllowedTags::$attributes,
194
+			'optgroup' => AllowedTags::$attributes,
195
+			'textarea' => AllowedTags::$attributes,
196
+			'button'   => AllowedTags::$attributes,
197
+			'fieldset' => AllowedTags::$attributes,
198
+			'output'   => AllowedTags::$attributes,
199
+		];
200
+		AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags);
201
+	}
202
+
203
+
204
+	/**
205
+	 * merges form script and style tags and attributes into the EE all tags
206
+	 */
207
+	private static function initializeWithScriptAndStyleTags()
208
+	{
209
+		$all_tags = AllowedTags::getAllowedTags();
210
+		$script_and_style_tags = [
211
+			'script'   => AllowedTags::$attributes,
212
+			'style'    => AllowedTags::$attributes,
213
+			'link'     => AllowedTags::$attributes,
214
+			'noscript' => AllowedTags::$attributes,
215
+		];
216
+		AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags);
217
+	}
218
+
219
+	/**
220
+	 * merges all head and body tags and attributes into the EE all tags
221
+	 */
222
+	private static function initializeWithFullTags()
223
+	{
224
+		$all_tags = AllowedTags::getAllowedTags();
225
+		$full_tags = [
226
+			'script'    => AllowedTags::$attributes,
227
+			'style'     => AllowedTags::$attributes,
228
+			'link'      => AllowedTags::$attributes,
229
+			'title'     => AllowedTags::$attributes,
230
+			'meta'      => AllowedTags::$attributes,
231
+			'iframe'    => AllowedTags::$attributes,
232
+			'form'      => AllowedTags::$attributes,
233
+			'label'     => AllowedTags::$attributes,
234
+			'input'     => AllowedTags::$attributes,
235
+			'select'    => AllowedTags::$attributes,
236
+			'option'    => AllowedTags::$attributes,
237
+			'optgroup'  => AllowedTags::$attributes,
238
+			'textarea'  => AllowedTags::$attributes,
239
+			'button'    => AllowedTags::$attributes,
240
+			'fieldset'  => AllowedTags::$attributes,
241
+			'output'    => AllowedTags::$attributes,
242
+			'noscript'  => AllowedTags::$attributes,
243
+			'html'      => AllowedTags::$attributes,
244
+			'body'      => AllowedTags::$attributes,
245
+			'head'      => AllowedTags::$attributes,
246
+		];
247
+		AllowedTags::$allowed_with_full_tags = array_merge_recursive($all_tags, $full_tags);
248
+	}
249
+
250
+
251
+	/**
252
+	 * @return array[]
253
+	 */
254
+	public static function getAllowedTags()
255
+	{
256
+		if (empty(AllowedTags::$allowed_tags)) {
257
+			AllowedTags::initializeAllowedTags();
258
+		}
259
+		return AllowedTags::$allowed_tags;
260
+	}
261
+
262
+
263
+	/**
264
+	 * @return array[]
265
+	 */
266
+	public static function getWithEmbedTags()
267
+	{
268
+		if (empty(AllowedTags::$allowed_with_embed_tags)) {
269
+			AllowedTags::initializeWithEmbedTags();
270
+		}
271
+		return AllowedTags::$allowed_with_embed_tags;
272
+	}
273
+
274
+
275
+	/**
276
+	 * @return array[]
277
+	 */
278
+	public static function getWithFormTags()
279
+	{
280
+		if (empty(AllowedTags::$allowed_with_form_tags)) {
281
+			AllowedTags::initializeWithFormTags();
282
+		}
283
+		return AllowedTags::$allowed_with_form_tags;
284
+	}
285
+
286
+
287
+	/**
288
+	 * @return array[]
289
+	 */
290
+	public static function getWithScriptAndStyleTags()
291
+	{
292
+		if (empty(AllowedTags::$allowed_with_script_and_style_tags)) {
293
+			AllowedTags::initializeWithScriptAndStyleTags();
294
+		}
295
+		return AllowedTags::$allowed_with_script_and_style_tags;
296
+	}
297
+
298
+
299
+	/**
300
+	 * @return array[]
301
+	 */
302
+	public static function getWithFullTags()
303
+	{
304
+		if (empty(AllowedTags::$allowed_with_full_tags)) {
305
+			AllowedTags::initializeWithFullTags();
306
+		}
307
+		return AllowedTags::$allowed_with_full_tags;
308
+	}
309 309
 }
Please login to merge, or discard this patch.