Completed
Branch master (87a62b)
by
unknown
18:29 queued 13:45
created
admin_pages/support/Support_Admin_Page.core.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
     protected function _installation()
119 119
     {
120
-        $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
120
+        $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_installation.template.php';
121 121
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
122 122
             $template_path,
123 123
             '',
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         $this->addMetaBox(
139 139
             "espresso_{$box}_settings",
140 140
             $label,
141
-            function ($post, $metabox) {
141
+            function($post, $metabox) {
142 142
                 EEH_Template::display_template(
143 143
                     $metabox['args']['template_path'],
144 144
                     $metabox['args']['template_args']
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                 $box,
174 174
                 $label,
175 175
                 array(
176
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
176
+                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php",
177 177
                     'template_args' => $this->_template_args,
178 178
                 )
179 179
             );
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
                 $box,
206 206
                 $label,
207 207
                 array(
208
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
208
+                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php",
209 209
                     'template_args' => $this->_template_args,
210 210
                 )
211 211
             );
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                 $box,
234 234
                 $label,
235 235
                 array(
236
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
236
+                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php",
237 237
                     'template_args' => $this->_template_args,
238 238
                 )
239 239
             );
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     protected function _developers()
245 245
     {
246 246
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
247
-            EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
247
+            EE_SUPPORT_ADMIN_TEMPLATE_PATH.'developers_admin_details.template.php',
248 248
             array(),
249 249
             true
250 250
         );
Please login to merge, or discard this patch.
Indentation   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -11,244 +11,244 @@
 block discarded – undo
11 11
  */
12 12
 class Support_Admin_Page extends EE_Admin_Page
13 13
 {
14
-    protected function _init_page_props()
15
-    {
16
-        $this->page_slug = EE_SUPPORT_PG_SLUG;
17
-        $this->page_label = esc_html__('Help & Support', 'event_espresso');
18
-        $this->_admin_base_url = EE_SUPPORT_ADMIN_URL;
19
-        $this->_admin_base_path = EE_SUPPORT_ADMIN;
20
-    }
21
-
22
-
23
-    protected function _ajax_hooks()
24
-    {
25
-    }
26
-
27
-
28
-    protected function _define_page_props()
29
-    {
30
-        $this->_labels = array();
31
-        $this->_admin_page_title = $this->page_label;
32
-    }
33
-
34
-
35
-    protected function _set_page_routes()
36
-    {
37
-        $this->_page_routes = array(
38
-            'default'    => array(
39
-                'func'       => '_contact_support',
40
-                'capability' => 'ee_read_ee',
41
-            ),
42
-            'developers' => array(
43
-                'func'       => '_developers',
44
-                'capability' => 'ee_read_ee',
45
-            ),
46
-            'shortcodes' => array(
47
-                'func'       => '_shortcodes',
48
-                'capability' => 'ee_read_ee',
49
-            ),
50
-        );
51
-    }
52
-
53
-
54
-    protected function _set_page_config()
55
-    {
56
-        $this->_page_config = array(
57
-            'default'    => array(
58
-                'nav'           => array(
59
-                    'label' => esc_html__('Support', 'event_espresso'),
60
-                    'icon' => 'dashicons-sos',
61
-                    'order' => 30,
62
-                ),
63
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
64
-                'require_nonce' => false,
65
-            ),
66
-            'developers' => array(
67
-                'nav'           => array(
68
-                    'label' => esc_html__('Developers', 'event_espresso'),
69
-                    'icon' => 'dashicons-coffee',
70
-                    'order' => 50,
71
-                ),
72
-                'metaboxes'     => $this->_default_espresso_metaboxes,
73
-                'require_nonce' => false,
74
-            ),
75
-            'shortcodes' => array(
76
-                'nav'           => array(
77
-                    'label' => esc_html__('Shortcodes', 'event_espresso'),
78
-                    'icon' => 'dashicons-shortcode',
79
-                    'order' => 60,
80
-                ),
81
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
82
-                'require_nonce' => false,
83
-            ),
84
-        );
85
-    }
86
-
87
-
88
-    // none of the below group are currently used for Support pages
89
-    protected function _add_screen_options()
90
-    {
91
-    }
92
-
93
-
94
-    protected function _add_feature_pointers()
95
-    {
96
-    }
97
-
98
-
99
-    public function admin_init()
100
-    {
101
-    }
102
-
103
-
104
-    public function admin_notices()
105
-    {
106
-    }
107
-
108
-
109
-    public function admin_footer_scripts()
110
-    {
111
-    }
112
-
113
-
114
-    public function load_scripts_styles()
115
-    {
116
-    }
117
-
118
-
119
-    protected function _installation()
120
-    {
121
-        $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
122
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
123
-            $template_path,
124
-            '',
125
-            true
126
-        );
127
-        $this->display_admin_page_with_sidebar();
128
-    }
129
-
130
-
131
-    protected function _resources()
132
-    {
133
-        $this->display_admin_page_with_sidebar();
134
-    }
135
-
136
-
137
-    protected function _add_settings_metabox($box, $label, array $args)
138
-    {
139
-        $this->addMetaBox(
140
-            "espresso_{$box}_settings",
141
-            $label,
142
-            function ($post, $metabox) {
143
-                EEH_Template::display_template(
144
-                    $metabox['args']['template_path'],
145
-                    $metabox['args']['template_args']
146
-                );
147
-            },
148
-            $this->_current_screen->id,
149
-            'normal',
150
-            'high',
151
-            apply_filters(
152
-                "FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array",
153
-                $args
154
-            )
155
-        );
156
-    }
157
-
158
-
159
-    protected function _resources_boxes()
160
-    {
161
-        $boxes = apply_filters(
162
-            'FHEE__Support_Admin_Page___resources_boxes__boxes_array',
163
-            array(
164
-                'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'),
165
-                'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'),
166
-                'hire_developer'            => esc_html__('Hire a Developer', 'event_espresso'),
167
-                'partners'                  => esc_html__('Partners', 'event_espresso'),
168
-                'recommended_plugins'       => esc_html__('Recommended Plugins', 'event_espresso'),
169
-                'other_resources'           => esc_html__('Other Resources', 'event_espresso'),
170
-            )
171
-        );
172
-        foreach ($boxes as $box => $label) {
173
-            $this->_add_settings_metabox(
174
-                $box,
175
-                $label,
176
-                array(
177
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
178
-                    'template_args' => $this->_template_args,
179
-                )
180
-            );
181
-        }
182
-    }
183
-
184
-
185
-    protected function _shortcodes()
186
-    {
187
-        $this->display_admin_page_with_sidebar();
188
-    }
189
-
190
-
191
-    protected function _shortcodes_boxes()
192
-    {
193
-        $boxes = apply_filters(
194
-            'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array',
195
-            array(
196
-                'shortcodes_event_listings'  => esc_html__('Event Listings', 'event_espresso'),
197
-                'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'),
198
-                'shortcodes_category'        => esc_html__('Event Categories', 'event_espresso'),
199
-                'shortcodes_attendee'        => esc_html__('Event Attendees', 'event_espresso')
200
-                /*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/
201
-                /*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/
202
-            )
203
-        );
204
-        foreach ($boxes as $box => $label) {
205
-            $this->_add_settings_metabox(
206
-                $box,
207
-                $label,
208
-                array(
209
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
210
-                    'template_args' => $this->_template_args,
211
-                )
212
-            );
213
-        }
214
-    }
215
-
216
-
217
-    protected function _contact_support()
218
-    {
219
-        $this->display_admin_page_with_sidebar();
220
-    }
221
-
222
-
223
-    protected function _support_boxes()
224
-    {
225
-        $boxes = apply_filters(
226
-            'FHEE__Support_Admin_Page___support_boxes__boxes_array',
227
-            array(
228
-                'contact_support'       => esc_html__('Contact Support', 'event_espresso'),
229
-                'important_information' => esc_html__('Important Information', 'event_espresso'),
230
-            )
231
-        );
232
-        foreach ($boxes as $box => $label) {
233
-            $this->_add_settings_metabox(
234
-                $box,
235
-                $label,
236
-                array(
237
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
238
-                    'template_args' => $this->_template_args,
239
-                )
240
-            );
241
-        }
242
-    }
243
-
244
-
245
-    protected function _developers()
246
-    {
247
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
248
-            EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
249
-            array(),
250
-            true
251
-        );
252
-        $this->display_admin_page_with_sidebar();
253
-    }
14
+	protected function _init_page_props()
15
+	{
16
+		$this->page_slug = EE_SUPPORT_PG_SLUG;
17
+		$this->page_label = esc_html__('Help & Support', 'event_espresso');
18
+		$this->_admin_base_url = EE_SUPPORT_ADMIN_URL;
19
+		$this->_admin_base_path = EE_SUPPORT_ADMIN;
20
+	}
21
+
22
+
23
+	protected function _ajax_hooks()
24
+	{
25
+	}
26
+
27
+
28
+	protected function _define_page_props()
29
+	{
30
+		$this->_labels = array();
31
+		$this->_admin_page_title = $this->page_label;
32
+	}
33
+
34
+
35
+	protected function _set_page_routes()
36
+	{
37
+		$this->_page_routes = array(
38
+			'default'    => array(
39
+				'func'       => '_contact_support',
40
+				'capability' => 'ee_read_ee',
41
+			),
42
+			'developers' => array(
43
+				'func'       => '_developers',
44
+				'capability' => 'ee_read_ee',
45
+			),
46
+			'shortcodes' => array(
47
+				'func'       => '_shortcodes',
48
+				'capability' => 'ee_read_ee',
49
+			),
50
+		);
51
+	}
52
+
53
+
54
+	protected function _set_page_config()
55
+	{
56
+		$this->_page_config = array(
57
+			'default'    => array(
58
+				'nav'           => array(
59
+					'label' => esc_html__('Support', 'event_espresso'),
60
+					'icon' => 'dashicons-sos',
61
+					'order' => 30,
62
+				),
63
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
64
+				'require_nonce' => false,
65
+			),
66
+			'developers' => array(
67
+				'nav'           => array(
68
+					'label' => esc_html__('Developers', 'event_espresso'),
69
+					'icon' => 'dashicons-coffee',
70
+					'order' => 50,
71
+				),
72
+				'metaboxes'     => $this->_default_espresso_metaboxes,
73
+				'require_nonce' => false,
74
+			),
75
+			'shortcodes' => array(
76
+				'nav'           => array(
77
+					'label' => esc_html__('Shortcodes', 'event_espresso'),
78
+					'icon' => 'dashicons-shortcode',
79
+					'order' => 60,
80
+				),
81
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
82
+				'require_nonce' => false,
83
+			),
84
+		);
85
+	}
86
+
87
+
88
+	// none of the below group are currently used for Support pages
89
+	protected function _add_screen_options()
90
+	{
91
+	}
92
+
93
+
94
+	protected function _add_feature_pointers()
95
+	{
96
+	}
97
+
98
+
99
+	public function admin_init()
100
+	{
101
+	}
102
+
103
+
104
+	public function admin_notices()
105
+	{
106
+	}
107
+
108
+
109
+	public function admin_footer_scripts()
110
+	{
111
+	}
112
+
113
+
114
+	public function load_scripts_styles()
115
+	{
116
+	}
117
+
118
+
119
+	protected function _installation()
120
+	{
121
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
122
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
123
+			$template_path,
124
+			'',
125
+			true
126
+		);
127
+		$this->display_admin_page_with_sidebar();
128
+	}
129
+
130
+
131
+	protected function _resources()
132
+	{
133
+		$this->display_admin_page_with_sidebar();
134
+	}
135
+
136
+
137
+	protected function _add_settings_metabox($box, $label, array $args)
138
+	{
139
+		$this->addMetaBox(
140
+			"espresso_{$box}_settings",
141
+			$label,
142
+			function ($post, $metabox) {
143
+				EEH_Template::display_template(
144
+					$metabox['args']['template_path'],
145
+					$metabox['args']['template_args']
146
+				);
147
+			},
148
+			$this->_current_screen->id,
149
+			'normal',
150
+			'high',
151
+			apply_filters(
152
+				"FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array",
153
+				$args
154
+			)
155
+		);
156
+	}
157
+
158
+
159
+	protected function _resources_boxes()
160
+	{
161
+		$boxes = apply_filters(
162
+			'FHEE__Support_Admin_Page___resources_boxes__boxes_array',
163
+			array(
164
+				'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'),
165
+				'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'),
166
+				'hire_developer'            => esc_html__('Hire a Developer', 'event_espresso'),
167
+				'partners'                  => esc_html__('Partners', 'event_espresso'),
168
+				'recommended_plugins'       => esc_html__('Recommended Plugins', 'event_espresso'),
169
+				'other_resources'           => esc_html__('Other Resources', 'event_espresso'),
170
+			)
171
+		);
172
+		foreach ($boxes as $box => $label) {
173
+			$this->_add_settings_metabox(
174
+				$box,
175
+				$label,
176
+				array(
177
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
178
+					'template_args' => $this->_template_args,
179
+				)
180
+			);
181
+		}
182
+	}
183
+
184
+
185
+	protected function _shortcodes()
186
+	{
187
+		$this->display_admin_page_with_sidebar();
188
+	}
189
+
190
+
191
+	protected function _shortcodes_boxes()
192
+	{
193
+		$boxes = apply_filters(
194
+			'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array',
195
+			array(
196
+				'shortcodes_event_listings'  => esc_html__('Event Listings', 'event_espresso'),
197
+				'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'),
198
+				'shortcodes_category'        => esc_html__('Event Categories', 'event_espresso'),
199
+				'shortcodes_attendee'        => esc_html__('Event Attendees', 'event_espresso')
200
+				/*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/
201
+				/*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/
202
+			)
203
+		);
204
+		foreach ($boxes as $box => $label) {
205
+			$this->_add_settings_metabox(
206
+				$box,
207
+				$label,
208
+				array(
209
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
210
+					'template_args' => $this->_template_args,
211
+				)
212
+			);
213
+		}
214
+	}
215
+
216
+
217
+	protected function _contact_support()
218
+	{
219
+		$this->display_admin_page_with_sidebar();
220
+	}
221
+
222
+
223
+	protected function _support_boxes()
224
+	{
225
+		$boxes = apply_filters(
226
+			'FHEE__Support_Admin_Page___support_boxes__boxes_array',
227
+			array(
228
+				'contact_support'       => esc_html__('Contact Support', 'event_espresso'),
229
+				'important_information' => esc_html__('Important Information', 'event_espresso'),
230
+			)
231
+		);
232
+		foreach ($boxes as $box => $label) {
233
+			$this->_add_settings_metabox(
234
+				$box,
235
+				$label,
236
+				array(
237
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
238
+					'template_args' => $this->_template_args,
239
+				)
240
+			);
241
+		}
242
+	}
243
+
244
+
245
+	protected function _developers()
246
+	{
247
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
248
+			EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
249
+			array(),
250
+			true
251
+		);
252
+		$this->display_admin_page_with_sidebar();
253
+	}
254 254
 }
Please login to merge, or discard this patch.
help_tabs/transactions_overview_views_filters_search.help_tab.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
 </p>
4 4
 <p>
5 5
     <?php esc_html_e(
6
-        'Views allow you to restrict what you see in the Transactions Overview table. The following views are available: View All. The number in parentheses next to each view represents the number of transactions that will be displayed with that view.',
7
-        'event_espresso'
8
-    ); ?>
6
+		'Views allow you to restrict what you see in the Transactions Overview table. The following views are available: View All. The number in parentheses next to each view represents the number of transactions that will be displayed with that view.',
7
+		'event_espresso'
8
+	); ?>
9 9
     <br />
10 10
 </p>
11 11
 <ul>
@@ -13,31 +13,31 @@  discard block
 block discarded – undo
13 13
         <strong><?php esc_html_e('View All Transactions', 'event_espresso'); ?></strong>
14 14
         <br />
15 15
         <?php printf(
16
-            esc_html__(
17
-                'Shows transactions where the registrant has completed the full registration process. Transactions in this view will either have a status of: %1$s%2$s"Incomplete" meaning there are monies owing%3$s%2$s"Complete" meaning there are NO monies owing%3$s%2$s"Overpaid" meaning that monies should be refunded to the registrant.%3$s%4$s',
18
-                'event_espresso'
19
-            ),
20
-            '<ul>',
21
-            '<li>',
22
-            '</li>',
23
-            '</ul>'
24
-        ); ?>
16
+			esc_html__(
17
+				'Shows transactions where the registrant has completed the full registration process. Transactions in this view will either have a status of: %1$s%2$s"Incomplete" meaning there are monies owing%3$s%2$s"Complete" meaning there are NO monies owing%3$s%2$s"Overpaid" meaning that monies should be refunded to the registrant.%3$s%4$s',
18
+				'event_espresso'
19
+			),
20
+			'<ul>',
21
+			'<li>',
22
+			'</li>',
23
+			'</ul>'
24
+		); ?>
25 25
     </li>
26 26
     <li>
27 27
         <strong><?php esc_html_e('Abandoned Transactions', 'event_espresso'); ?></strong>
28 28
         <br />
29 29
         <?php esc_html_e(
30
-            'Shows transactions that have been abandoned, either due to a technical reason (server or computer crash during registration), or due to an abandoned cart where the registrant chose not to complete the registration process. Please note that Abandoned Transactions were able to capture contact information for at least one registrant. This can be helpful for following up with the contact to determine if they still wish to attend the event or not.',
31
-            'event_espresso'
32
-        ); ?>
30
+			'Shows transactions that have been abandoned, either due to a technical reason (server or computer crash during registration), or due to an abandoned cart where the registrant chose not to complete the registration process. Please note that Abandoned Transactions were able to capture contact information for at least one registrant. This can be helpful for following up with the contact to determine if they still wish to attend the event or not.',
31
+			'event_espresso'
32
+		); ?>
33 33
     </li>
34 34
     <li>
35 35
         <strong><?php esc_html_e('Failed Transactions', 'event_espresso'); ?></strong>
36 36
         <br />
37 37
         <?php esc_html_e(
38
-            'Shows transactions that have failed, either due to a technical reason (server or computer crash during registration), or some other reason that prevented the collection of any useful contact information from any of the registrants. This could mean the registrant abandoned the registration process before submitting any data whatsoever or may even indicate attempts by spam bots to submit the registration form.',
39
-            'event_espresso'
40
-        ); ?>
38
+			'Shows transactions that have failed, either due to a technical reason (server or computer crash during registration), or some other reason that prevented the collection of any useful contact information from any of the registrants. This could mean the registrant abandoned the registration process before submitting any data whatsoever or may even indicate attempts by spam bots to submit the registration form.',
39
+			'event_espresso'
40
+		); ?>
41 41
     </li>
42 42
 </ul>
43 43
 <p>
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 </p>
59 59
 <p>
60 60
     <?php esc_html_e(
61
-        'You can perform a search to find specific transactions. The following sources will be searched: Event Name (title), Event Description, First Name, Last Name, Bio, Email, Address, Comments, Notes, Registration Final Price, Registration Code, Registration Group Size, Ticket Name, Ticket Description, Payment Method, Payment Gateway, Transaction Details, and Transaction Session Data. To use the search feature, enter a value into the search box and click on the Search Transactions button.',
62
-        'event_espresso'
63
-    ); ?>
61
+		'You can perform a search to find specific transactions. The following sources will be searched: Event Name (title), Event Description, First Name, Last Name, Bio, Email, Address, Comments, Notes, Registration Final Price, Registration Code, Registration Group Size, Ticket Name, Ticket Description, Payment Method, Payment Gateway, Transaction Details, and Transaction Session Data. To use the search feature, enter a value into the search box and click on the Search Transactions button.',
62
+		'event_espresso'
63
+	); ?>
64 64
 </p>
Please login to merge, or discard this patch.
admin_pages/registrations/templates/reg_admin_details_header.template.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@
 block discarded – undo
37 37
         <span class='ee-admin-page-nav-strip-item'>
38 38
         <?php echo sprintf(
39 39
             esc_html__('View %1$sRegistrations%4$s /  %2$sTransactions%4$s for this %3$sevent%4$s.', 'event_espresso'),
40
-            '<a href="' . esc_url_raw($filtered_registrations_link) . '">',
41
-            '<a href="' . esc_url_raw($filtered_registrations_link) . '">',
42
-            '<a href="' . esc_url_raw($event_link) . '">',
40
+            '<a href="'.esc_url_raw($filtered_registrations_link).'">',
41
+            '<a href="'.esc_url_raw($filtered_registrations_link).'">',
42
+            '<a href="'.esc_url_raw($event_link).'">',
43 43
             '</a>'
44 44
         ); ?>
45 45
         </span>
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -19,36 +19,36 @@
 block discarded – undo
19 19
 <div class='ee-admin-page-nav-strip-wrap'>
20 20
     <div class='ee-admin-page-nav-strip'>
21 21
         <?php
22
-        echo wp_kses($previous_registration, AllowedTags::getAllowedTags());
23
-        echo '<span>';
24
-        printf(
25
-            /* translators: %s: registration number */
26
-            esc_html__('Registration # %1$s', 'event_espresso'),
27
-            esc_html($reg_nmbr['value'])
28
-        );
29
-        echo '</span>';
30
-        echo wp_kses($next_registration, AllowedTags::getAllowedTags());
31
-        ?>
22
+		echo wp_kses($previous_registration, AllowedTags::getAllowedTags());
23
+		echo '<span>';
24
+		printf(
25
+			/* translators: %s: registration number */
26
+			esc_html__('Registration # %1$s', 'event_espresso'),
27
+			esc_html($reg_nmbr['value'])
28
+		);
29
+		echo '</span>';
30
+		echo wp_kses($next_registration, AllowedTags::getAllowedTags());
31
+		?>
32 32
     </div>
33 33
     <div class='ee-admin-page-nav-strip'>
34 34
         <?php if ($registration->group_size() > 1) : ?>
35 35
             <span class='ee-admin-page-nav-strip-item'>
36 36
             <a id="scroll-to-other-attendees" class="scroll-to" href="#other-attendees">
37 37
                 <?php echo esc_html__(
38
-                    'Scroll to Other Registrations in the Same Transaction',
39
-                    'event_espresso'
40
-                ); ?>
38
+					'Scroll to Other Registrations in the Same Transaction',
39
+					'event_espresso'
40
+				); ?>
41 41
             </a>
42 42
         </span>
43 43
         <?php endif; ?>
44 44
         <span class='ee-admin-page-nav-strip-item'>
45 45
         <?php echo sprintf(
46
-            esc_html__('View %1$sRegistrations%4$s /  %2$sTransactions%4$s for this %3$sevent%4$s.', 'event_espresso'),
47
-            '<a href="' . esc_url_raw($filtered_registrations_link) . '">',
48
-            '<a href="' . esc_url_raw($filtered_registrations_link) . '">',
49
-            '<a href="' . esc_url_raw($event_link) . '">',
50
-            '</a>'
51
-        ); ?>
46
+			esc_html__('View %1$sRegistrations%4$s /  %2$sTransactions%4$s for this %3$sevent%4$s.', 'event_espresso'),
47
+			'<a href="' . esc_url_raw($filtered_registrations_link) . '">',
48
+			'<a href="' . esc_url_raw($filtered_registrations_link) . '">',
49
+			'<a href="' . esc_url_raw($event_link) . '">',
50
+			'</a>'
51
+		); ?>
52 52
         </span>
53 53
     </div>
54 54
 </div>
Please login to merge, or discard this patch.
core/helpers/EEH_Qtip_Loader.helper.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     public static function instance()
43 43
     {
44 44
         // check if class object is instantiated
45
-        if (! EEH_Qtip_Loader::$_instance instanceof EEH_Qtip_Loader) {
45
+        if ( ! EEH_Qtip_Loader::$_instance instanceof EEH_Qtip_Loader) {
46 46
             EEH_Qtip_Loader::$_instance = new EEH_Qtip_Loader();
47 47
         }
48 48
         return EEH_Qtip_Loader::$_instance;
@@ -78,19 +78,19 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function register_and_enqueue()
80 80
     {
81
-        $qtips_js = !defined('SCRIPT_DEBUG')
81
+        $qtips_js = ! defined('SCRIPT_DEBUG')
82 82
             ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js'
83
-            : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js';
84
-        $qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map';
85
-        $qtip_css = !defined('SCRIPT_DEBUG')
83
+            : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.js';
84
+        $qtip_map = EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.map';
85
+        $qtip_css = ! defined('SCRIPT_DEBUG')
86 86
             ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css'
87
-            : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css';
87
+            : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.css';
88 88
 
89 89
         wp_register_script('qtip-map', $qtip_map, array(), '3', true);
90 90
         wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true);
91 91
         wp_register_script(
92 92
             'ee-qtip-helper',
93
-            EE_HELPERS_ASSETS . 'ee-qtip-helper.js',
93
+            EE_HELPERS_ASSETS.'ee-qtip-helper.js',
94 94
             array('qtip', JqueryAssetManager::JS_HANDLE_JQUERY_COOKIE),
95 95
             EVENT_ESPRESSO_VERSION,
96 96
             true
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
         // k now let's see if there are any registered qtips.
102 102
         // If there are, then we need to setup the localized script for ee-qtip-helper.js
103 103
         // (and enqueue ee-qtip-helper.js of course!)
104
-        if (!empty($this->_qtips)) {
104
+        if ( ! empty($this->_qtips)) {
105 105
             wp_enqueue_script('ee-qtip-helper');
106 106
             wp_enqueue_style('qtip-css');
107 107
             $qtips = array();
108 108
             foreach ($this->_qtips as $qtip) {
109 109
                 $qts = $qtip->get_tips();
110 110
                 foreach ($qts as $qt) {
111
-                    if (! $qt instanceof EE_Qtip) {
111
+                    if ( ! $qt instanceof EE_Qtip) {
112 112
                         continue;
113 113
                     }
114 114
                     $qtips[] = array(
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
                         );
119 119
                 }
120 120
             }
121
-            if (!empty($qtips)) {
122
-                wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ));
121
+            if ( ! empty($qtips)) {
122
+                wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips));
123 123
             }
124 124
         } else {
125 125
             // qtips has been requested without any registration (so assuming its just directly used in the admin).
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
     {
191 191
         // before doing anything we have to make sure that EE_Qtip_Config parent is required.
192 192
         EE_Registry::instance()->load_lib('Qtip_Config', array(), true);
193
-        if (!empty($paths)) {
193
+        if ( ! empty($paths)) {
194 194
             $paths = (array) $paths;
195 195
             foreach ($paths as $path) {
196
-                $path .= $qtip . '.lib.php';
196
+                $path .= $qtip.'.lib.php';
197 197
                 if (is_readable($path)) {
198 198
                     require_once $path;
199 199
                 }
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
         }
202 202
 
203 203
         // does class exist at this point?  If it does then let's instantiate.  If it doesn't then let's continue with other paths.
204
-        if (! class_exists($qtip)) {
205
-            $path = EE_LIBRARIES . 'qtips/' . $qtip . '.lib.php';
206
-            if (! is_readable($path)) {
204
+        if ( ! class_exists($qtip)) {
205
+            $path = EE_LIBRARIES.'qtips/'.$qtip.'.lib.php';
206
+            if ( ! is_readable($path)) {
207 207
                 throw new DomainException(
208 208
                     sprintf(
209 209
                         esc_html__(
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
         }
219 219
 
220 220
         // now we attempt a class_exists one more time.
221
-        if (! class_exists($qtip)) {
221
+        if ( ! class_exists($qtip)) {
222 222
             throw new DomainException(
223 223
                 sprintf(
224 224
                     esc_html__(
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
         $qtip_config = $this->loader->getShared($qtip);
235 235
 
236 236
         // verify that $qtip is a valid object
237
-        if (! $qtip_config instanceof EE_Qtip_Config) {
237
+        if ( ! $qtip_config instanceof EE_Qtip_Config) {
238 238
             throw new DomainException(
239 239
                 sprintf(
240 240
                     esc_html__(
@@ -286,11 +286,11 @@  discard block
 block discarded – undo
286 286
         $qts = $qtip->get_tips();
287 287
         $content = array();
288 288
         foreach ($qts as $qt) {
289
-            if (! $qt instanceof EE_Qtip) {
289
+            if ( ! $qt instanceof EE_Qtip) {
290 290
                 continue;
291 291
             }
292
-            $content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' .
293
-                         $qt->content . '</div>';
292
+            $content[] = '<div class="ee-qtip-helper-content hidden" id="'.esc_attr($qt->content_id).'">'.
293
+                         $qt->content.'</div>';
294 294
         }
295 295
 
296 296
         return implode('<br />', $content);
Please login to merge, or discard this patch.
Indentation   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -15,283 +15,283 @@
 block discarded – undo
15 15
  */
16 16
 class EEH_Qtip_Loader extends EEH_Base
17 17
 {
18
-    /**
19
-     * @var LoaderInterface $loader
20
-     */
21
-    protected $loader;
22
-
23
-    /**
24
-     * @var EEH_Qtip_Loader
25
-     */
26
-    private static $_instance;
27
-
28
-    /**
29
-     * array of qtip config objects
30
-     * @var EE_Qtip_Config[]
31
-     */
32
-    private $_qtips = array();
33
-
34
-
35
-
36
-    /**
37
-     *@singleton method used to instantiate class object
38
-     *@access public
39
-     *@return EEH_Qtip_Loader instance
40
-     */
41
-    public static function instance()
42
-    {
43
-        // check if class object is instantiated
44
-        if (! EEH_Qtip_Loader::$_instance instanceof EEH_Qtip_Loader) {
45
-            EEH_Qtip_Loader::$_instance = new EEH_Qtip_Loader();
46
-        }
47
-        return EEH_Qtip_Loader::$_instance;
48
-    }
49
-
50
-
51
-
52
-    /**
53
-     * private constructor to prevent direct creation
54
-     */
55
-    private function __construct()
56
-    {
57
-        // let's just make sure this is instantiated in the right place.
58
-        if (did_action('wp_print_styles') || did_action('admin_head')) {
59
-            EE_Error::doing_it_wrong(
60
-                'EEH_Qtip_Loader',
61
-                esc_html__(
62
-                    'This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.',
63
-                    'event_espresso'
64
-                ),
65
-                '4.1'
66
-            );
67
-        }
68
-        $this->loader = LoaderFactory::getLoader();
69
-    }
70
-
71
-
72
-    /**
73
-     * Call this from wp_enqueue_scripts or admin_enqueue_scripts to setup and enqueue the qtip library
74
-     *
75
-     * @access public
76
-     * @return void
77
-     */
78
-    public function register_and_enqueue()
79
-    {
80
-        $qtips_js = !defined('SCRIPT_DEBUG')
81
-            ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js'
82
-            : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js';
83
-        $qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map';
84
-        $qtip_css = !defined('SCRIPT_DEBUG')
85
-            ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css'
86
-            : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css';
87
-
88
-        wp_register_script('qtip-map', $qtip_map, array(), '3', true);
89
-        wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true);
90
-        wp_register_script(
91
-            'ee-qtip-helper',
92
-            EE_HELPERS_ASSETS . 'ee-qtip-helper.js',
93
-            array('qtip', JqueryAssetManager::JS_HANDLE_JQUERY_COOKIE),
94
-            EVENT_ESPRESSO_VERSION,
95
-            true
96
-        );
97
-
98
-        wp_register_style('qtip-css', $qtip_css, array(), '2.2');
99
-
100
-        // k now let's see if there are any registered qtips.
101
-        // If there are, then we need to setup the localized script for ee-qtip-helper.js
102
-        // (and enqueue ee-qtip-helper.js of course!)
103
-        if (!empty($this->_qtips)) {
104
-            wp_enqueue_script('ee-qtip-helper');
105
-            wp_enqueue_style('qtip-css');
106
-            $qtips = array();
107
-            foreach ($this->_qtips as $qtip) {
108
-                $qts = $qtip->get_tips();
109
-                foreach ($qts as $qt) {
110
-                    if (! $qt instanceof EE_Qtip) {
111
-                        continue;
112
-                    }
113
-                    $qtips[] = array(
114
-                        'content_id' => $qt->content_id,
115
-                        'options' => $qt->options,
116
-                        'target' => $qt->target,
117
-                        );
118
-                }
119
-            }
120
-            if (!empty($qtips)) {
121
-                wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ));
122
-            }
123
-        } else {
124
-            // qtips has been requested without any registration (so assuming its just directly used in the admin).
125
-            wp_enqueue_script('qtip');
126
-            wp_enqueue_style('qtip-css');
127
-        }
128
-    }
129
-
130
-
131
-    /**
132
-     * This simply registers the given qtip config and:
133
-     * - adds it to the $_qtips property array.
134
-     * - sets up the content containers for all qtips in the config,
135
-     * - registers and enqueues the qtip scripts and styles.
136
-     *
137
-     * @access public
138
-     * @param array        $paths      Array of paths to check for the EE_Qtip class. If present we check these path(s)
139
-     *                                 first.  If not present (empty array), then it's assumed it's either in
140
-     *                                 core/libraries/qtips OR the file is already loaded.
141
-     * @param string|array $qtips      name of the Qtip class (full class name is expected and will be used for looking
142
-     *                                 for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array,
143
-     *                                 then we loop through the array to instantiate and setup the qtips]
144
-     * @return void
145
-     * @throws DomainException
146
-     * @throws EE_Error
147
-     * @throws ReflectionException
148
-     */
149
-    public function register($qtips, $paths = array())
150
-    {
151
-        // let's just make sure this is instantiated in the right place.
152
-        if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
153
-            EE_Error::doing_it_wrong(
154
-                'EEH_Qtip_Loader->register()',
155
-                esc_html__(
156
-                    'EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.',
157
-                    'event_espresso'
158
-                ),
159
-                '4.1'
160
-            );
161
-        }
162
-
163
-        $qtips = (array) $qtips; // typecast to array
164
-        foreach ($qtips as $qtip) {
165
-            $this->_qtips[] = $this->_register($qtip, $paths);
166
-        }
167
-
168
-        // hook into appropriate footer
169
-        $footer_action = is_admin() ? 'admin_footer' : 'wp_footer';
170
-        add_action($footer_action, array($this, 'setup_qtip'), 10);
171
-
172
-        // make sure we "turn on" qtip js.
173
-        add_filter('FHEE_load_qtip', '__return_true');
174
-    }
175
-
176
-
177
-    /**
178
-     * private utility for registering and setting up qtip config objects
179
-     *
180
-     * @access private
181
-     * @param string $qtip  the short name of the class (will be used to generate the expected classname)
182
-     * @param array  $paths array of paths to check (or if empty we check core/libraries/qtips or assume its loaded)
183
-     * @return EE_Qtip_Config
184
-     * @throws DomainException
185
-     * @throws EE_Error
186
-     * @throws ReflectionException
187
-     */
188
-    private function _register($qtip, $paths)
189
-    {
190
-        // before doing anything we have to make sure that EE_Qtip_Config parent is required.
191
-        EE_Registry::instance()->load_lib('Qtip_Config', array(), true);
192
-        if (!empty($paths)) {
193
-            $paths = (array) $paths;
194
-            foreach ($paths as $path) {
195
-                $path .= $qtip . '.lib.php';
196
-                if (is_readable($path)) {
197
-                    require_once $path;
198
-                }
199
-            }
200
-        }
201
-
202
-        // does class exist at this point?  If it does then let's instantiate.  If it doesn't then let's continue with other paths.
203
-        if (! class_exists($qtip)) {
204
-            $path = EE_LIBRARIES . 'qtips/' . $qtip . '.lib.php';
205
-            if (! is_readable($path)) {
206
-                throw new DomainException(
207
-                    sprintf(
208
-                        esc_html__(
209
-                            'Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable.  Please check the spelling of the paths you\'ve used in the registration',
210
-                            'event_espresso'
211
-                        ),
212
-                        $qtip
213
-                    )
214
-                );
215
-            }
216
-            require_once $path;
217
-        }
218
-
219
-        // now we attempt a class_exists one more time.
220
-        if (! class_exists($qtip)) {
221
-            throw new DomainException(
222
-                sprintf(
223
-                    esc_html__(
224
-                        'The Qtip_Config class being registered (%s) does not exist, please check the spelling.',
225
-                        'event_espresso'
226
-                    ),
227
-                    $qtip
228
-                )
229
-            );
230
-        }
231
-
232
-        // made it HERE?  FINALLY, let's get things setup.
233
-        $qtip_config = $this->loader->getShared($qtip);
234
-
235
-        // verify that $qtip is a valid object
236
-        if (! $qtip_config instanceof EE_Qtip_Config) {
237
-            throw new DomainException(
238
-                sprintf(
239
-                    esc_html__(
240
-                        'The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.',
241
-                        'event_espresso'
242
-                    ),
243
-                    $qtip,
244
-                    '<strong>',
245
-                    '</strong>'
246
-                )
247
-            );
248
-        }
249
-
250
-        return $qtip_config;
251
-    }
252
-
253
-
254
-
255
-    /**
256
-     * This takes care of generating the qtip content containers.
257
-     * Output gets put in the appropriate page footer (depending on context (either admin_footer or wp_footer) )
258
-     *
259
-     * @return void
260
-     */
261
-    public function setup_qtip()
262
-    {
263
-        if (empty($this->_qtips)) {
264
-            return; // no qtips!
265
-        }
266
-
267
-        $content = array();
268
-
269
-        foreach ($this->_qtips as $qtip) {
270
-            $content[] = $this->_generate_content_container($qtip);
271
-        }
272
-
273
-        echo implode('<br />', $content);
274
-    }
275
-
276
-
277
-    /**
278
-     * Generates a content container from a given EE_Qtip_Config object.
279
-     *
280
-     * @param  EE_Qtip_Config $qtip
281
-     * @return string  (html content container for qtip);
282
-     */
283
-    private function _generate_content_container($qtip)
284
-    {
285
-        $qts = $qtip->get_tips();
286
-        $content = array();
287
-        foreach ($qts as $qt) {
288
-            if (! $qt instanceof EE_Qtip) {
289
-                continue;
290
-            }
291
-            $content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' .
292
-                         $qt->content . '</div>';
293
-        }
294
-
295
-        return implode('<br />', $content);
296
-    }
18
+	/**
19
+	 * @var LoaderInterface $loader
20
+	 */
21
+	protected $loader;
22
+
23
+	/**
24
+	 * @var EEH_Qtip_Loader
25
+	 */
26
+	private static $_instance;
27
+
28
+	/**
29
+	 * array of qtip config objects
30
+	 * @var EE_Qtip_Config[]
31
+	 */
32
+	private $_qtips = array();
33
+
34
+
35
+
36
+	/**
37
+	 *@singleton method used to instantiate class object
38
+	 *@access public
39
+	 *@return EEH_Qtip_Loader instance
40
+	 */
41
+	public static function instance()
42
+	{
43
+		// check if class object is instantiated
44
+		if (! EEH_Qtip_Loader::$_instance instanceof EEH_Qtip_Loader) {
45
+			EEH_Qtip_Loader::$_instance = new EEH_Qtip_Loader();
46
+		}
47
+		return EEH_Qtip_Loader::$_instance;
48
+	}
49
+
50
+
51
+
52
+	/**
53
+	 * private constructor to prevent direct creation
54
+	 */
55
+	private function __construct()
56
+	{
57
+		// let's just make sure this is instantiated in the right place.
58
+		if (did_action('wp_print_styles') || did_action('admin_head')) {
59
+			EE_Error::doing_it_wrong(
60
+				'EEH_Qtip_Loader',
61
+				esc_html__(
62
+					'This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.',
63
+					'event_espresso'
64
+				),
65
+				'4.1'
66
+			);
67
+		}
68
+		$this->loader = LoaderFactory::getLoader();
69
+	}
70
+
71
+
72
+	/**
73
+	 * Call this from wp_enqueue_scripts or admin_enqueue_scripts to setup and enqueue the qtip library
74
+	 *
75
+	 * @access public
76
+	 * @return void
77
+	 */
78
+	public function register_and_enqueue()
79
+	{
80
+		$qtips_js = !defined('SCRIPT_DEBUG')
81
+			? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js'
82
+			: EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js';
83
+		$qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map';
84
+		$qtip_css = !defined('SCRIPT_DEBUG')
85
+			? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css'
86
+			: EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css';
87
+
88
+		wp_register_script('qtip-map', $qtip_map, array(), '3', true);
89
+		wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true);
90
+		wp_register_script(
91
+			'ee-qtip-helper',
92
+			EE_HELPERS_ASSETS . 'ee-qtip-helper.js',
93
+			array('qtip', JqueryAssetManager::JS_HANDLE_JQUERY_COOKIE),
94
+			EVENT_ESPRESSO_VERSION,
95
+			true
96
+		);
97
+
98
+		wp_register_style('qtip-css', $qtip_css, array(), '2.2');
99
+
100
+		// k now let's see if there are any registered qtips.
101
+		// If there are, then we need to setup the localized script for ee-qtip-helper.js
102
+		// (and enqueue ee-qtip-helper.js of course!)
103
+		if (!empty($this->_qtips)) {
104
+			wp_enqueue_script('ee-qtip-helper');
105
+			wp_enqueue_style('qtip-css');
106
+			$qtips = array();
107
+			foreach ($this->_qtips as $qtip) {
108
+				$qts = $qtip->get_tips();
109
+				foreach ($qts as $qt) {
110
+					if (! $qt instanceof EE_Qtip) {
111
+						continue;
112
+					}
113
+					$qtips[] = array(
114
+						'content_id' => $qt->content_id,
115
+						'options' => $qt->options,
116
+						'target' => $qt->target,
117
+						);
118
+				}
119
+			}
120
+			if (!empty($qtips)) {
121
+				wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ));
122
+			}
123
+		} else {
124
+			// qtips has been requested without any registration (so assuming its just directly used in the admin).
125
+			wp_enqueue_script('qtip');
126
+			wp_enqueue_style('qtip-css');
127
+		}
128
+	}
129
+
130
+
131
+	/**
132
+	 * This simply registers the given qtip config and:
133
+	 * - adds it to the $_qtips property array.
134
+	 * - sets up the content containers for all qtips in the config,
135
+	 * - registers and enqueues the qtip scripts and styles.
136
+	 *
137
+	 * @access public
138
+	 * @param array        $paths      Array of paths to check for the EE_Qtip class. If present we check these path(s)
139
+	 *                                 first.  If not present (empty array), then it's assumed it's either in
140
+	 *                                 core/libraries/qtips OR the file is already loaded.
141
+	 * @param string|array $qtips      name of the Qtip class (full class name is expected and will be used for looking
142
+	 *                                 for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array,
143
+	 *                                 then we loop through the array to instantiate and setup the qtips]
144
+	 * @return void
145
+	 * @throws DomainException
146
+	 * @throws EE_Error
147
+	 * @throws ReflectionException
148
+	 */
149
+	public function register($qtips, $paths = array())
150
+	{
151
+		// let's just make sure this is instantiated in the right place.
152
+		if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
153
+			EE_Error::doing_it_wrong(
154
+				'EEH_Qtip_Loader->register()',
155
+				esc_html__(
156
+					'EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.',
157
+					'event_espresso'
158
+				),
159
+				'4.1'
160
+			);
161
+		}
162
+
163
+		$qtips = (array) $qtips; // typecast to array
164
+		foreach ($qtips as $qtip) {
165
+			$this->_qtips[] = $this->_register($qtip, $paths);
166
+		}
167
+
168
+		// hook into appropriate footer
169
+		$footer_action = is_admin() ? 'admin_footer' : 'wp_footer';
170
+		add_action($footer_action, array($this, 'setup_qtip'), 10);
171
+
172
+		// make sure we "turn on" qtip js.
173
+		add_filter('FHEE_load_qtip', '__return_true');
174
+	}
175
+
176
+
177
+	/**
178
+	 * private utility for registering and setting up qtip config objects
179
+	 *
180
+	 * @access private
181
+	 * @param string $qtip  the short name of the class (will be used to generate the expected classname)
182
+	 * @param array  $paths array of paths to check (or if empty we check core/libraries/qtips or assume its loaded)
183
+	 * @return EE_Qtip_Config
184
+	 * @throws DomainException
185
+	 * @throws EE_Error
186
+	 * @throws ReflectionException
187
+	 */
188
+	private function _register($qtip, $paths)
189
+	{
190
+		// before doing anything we have to make sure that EE_Qtip_Config parent is required.
191
+		EE_Registry::instance()->load_lib('Qtip_Config', array(), true);
192
+		if (!empty($paths)) {
193
+			$paths = (array) $paths;
194
+			foreach ($paths as $path) {
195
+				$path .= $qtip . '.lib.php';
196
+				if (is_readable($path)) {
197
+					require_once $path;
198
+				}
199
+			}
200
+		}
201
+
202
+		// does class exist at this point?  If it does then let's instantiate.  If it doesn't then let's continue with other paths.
203
+		if (! class_exists($qtip)) {
204
+			$path = EE_LIBRARIES . 'qtips/' . $qtip . '.lib.php';
205
+			if (! is_readable($path)) {
206
+				throw new DomainException(
207
+					sprintf(
208
+						esc_html__(
209
+							'Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable.  Please check the spelling of the paths you\'ve used in the registration',
210
+							'event_espresso'
211
+						),
212
+						$qtip
213
+					)
214
+				);
215
+			}
216
+			require_once $path;
217
+		}
218
+
219
+		// now we attempt a class_exists one more time.
220
+		if (! class_exists($qtip)) {
221
+			throw new DomainException(
222
+				sprintf(
223
+					esc_html__(
224
+						'The Qtip_Config class being registered (%s) does not exist, please check the spelling.',
225
+						'event_espresso'
226
+					),
227
+					$qtip
228
+				)
229
+			);
230
+		}
231
+
232
+		// made it HERE?  FINALLY, let's get things setup.
233
+		$qtip_config = $this->loader->getShared($qtip);
234
+
235
+		// verify that $qtip is a valid object
236
+		if (! $qtip_config instanceof EE_Qtip_Config) {
237
+			throw new DomainException(
238
+				sprintf(
239
+					esc_html__(
240
+						'The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.',
241
+						'event_espresso'
242
+					),
243
+					$qtip,
244
+					'<strong>',
245
+					'</strong>'
246
+				)
247
+			);
248
+		}
249
+
250
+		return $qtip_config;
251
+	}
252
+
253
+
254
+
255
+	/**
256
+	 * This takes care of generating the qtip content containers.
257
+	 * Output gets put in the appropriate page footer (depending on context (either admin_footer or wp_footer) )
258
+	 *
259
+	 * @return void
260
+	 */
261
+	public function setup_qtip()
262
+	{
263
+		if (empty($this->_qtips)) {
264
+			return; // no qtips!
265
+		}
266
+
267
+		$content = array();
268
+
269
+		foreach ($this->_qtips as $qtip) {
270
+			$content[] = $this->_generate_content_container($qtip);
271
+		}
272
+
273
+		echo implode('<br />', $content);
274
+	}
275
+
276
+
277
+	/**
278
+	 * Generates a content container from a given EE_Qtip_Config object.
279
+	 *
280
+	 * @param  EE_Qtip_Config $qtip
281
+	 * @return string  (html content container for qtip);
282
+	 */
283
+	private function _generate_content_container($qtip)
284
+	{
285
+		$qts = $qtip->get_tips();
286
+		$content = array();
287
+		foreach ($qts as $qt) {
288
+			if (! $qt instanceof EE_Qtip) {
289
+				continue;
290
+			}
291
+			$content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' .
292
+						 $qt->content . '</div>';
293
+		}
294
+
295
+		return implode('<br />', $content);
296
+	}
297 297
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Tabbed_Content.helper.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     {
31 31
 
32 32
         // first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston
33
-        if (! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
33
+        if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
34 34
             throw new EE_Error(
35 35
                 esc_html__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')
36 36
             );
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 
50 50
         $index = 0;
51 51
         foreach ($tabs as $tab) {
52
-            $active            = $index === 0;
52
+            $active = $index === 0;
53 53
             $tabs_html         .= self::tab($tab, $active);
54
-            $tabs_content_html .= self::tab_content($tab, $tabs_content[ $tab ], $active);
54
+            $tabs_content_html .= self::tab_content($tab, $tabs_content[$tab], $active);
55 55
             $index++;
56 56
         }
57 57
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
     {
119 119
         $nice_name = $nice_name ?: esc_html(ucwords(str_replace(['_', '-'], ' ', $name)));
120 120
         $name      = self::generateTabID($name);
121
-        $class     = $css ? ' ' . esc_attr($css) : '';
122
-        $class     .= $active ? ' nav-tab-active' : '';
123
-        $url       = $url ?: '#' . esc_attr($name);
121
+        $class     = $css ? ' '.esc_attr($css) : '';
122
+        $class .= $active ? ' nav-tab-active' : '';
123
+        $url       = $url ?: '#'.esc_attr($name);
124 124
         return "
125 125
         <a class='nav-tab{$class}' rel='{$name}' href='{$url}'>
126 126
             $nice_name
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     private static function generateTabID($tab_name)
138 138
     {
139
-        return 'ee-tab-' . esc_attr(str_replace(' ', '-', $tab_name));
139
+        return 'ee-tab-'.esc_attr(str_replace(' ', '-', $tab_name));
140 140
     }
141 141
 
142 142
 
@@ -187,18 +187,18 @@  discard block
 block discarded – undo
187 187
     public static function tab_text_links(array $item_array, $container_class = '', $sep = '|', $default = '')
188 188
     {
189 189
         $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class);
190
-        if (! is_array($item_array) || empty($item_array)) {
190
+        if ( ! is_array($item_array) || empty($item_array)) {
191 191
             return false; // get out we don't have even the basic thing we need!
192 192
         }
193 193
 
194
-        $defaults        = [
194
+        $defaults = [
195 195
             'label' => esc_html__('Item', 'event_espresso'),
196 196
             'class' => '',
197 197
             'href'  => '',
198 198
             'title' => esc_attr__('Link for Item', 'event_espresso'),
199 199
             'slug'  => 'item_slug',
200 200
         ];
201
-        $container_class = ! empty($container_class) ? ' ' . esc_attr($container_class) : '';
201
+        $container_class = ! empty($container_class) ? ' '.esc_attr($container_class) : '';
202 202
         $list            = '';
203 203
         $list_length     = count($item_array);
204 204
         // if we're' adding separators, set $current to 1, otherwise set it to list length + 1
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         // (if we aren't adding separators $current will always be > list length cuz it started at list length + 1)
207 207
         $current = empty($sep) ? $list_length + 1 : 1;
208 208
         foreach ($item_array as $item) {
209
-            $item          = wp_parse_args($item, $defaults);
209
+            $item = wp_parse_args($item, $defaults);
210 210
             $item['class'] .= $default === $item['slug'] ? ' item_display' : '';
211 211
             $list          .= self::textLinkItem($item);
212 212
             $list          .= $current < $list_length ? self::textLinkSeparator($sep) : '';
Please login to merge, or discard this patch.
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -13,249 +13,249 @@
 block discarded – undo
13 13
  */
14 14
 class EEH_Tabbed_Content
15 15
 {
16
-    /**
17
-     * assembles and returns the html structure for tabs
18
-     *
19
-     * @static
20
-     * @param array $tabs_contents an array of the content for each tab [required]
21
-     * @param array $tabs_names    a numerically indexed array of names for each tab [optional]
22
-     *                             - if this isn't included then we use the indexes for $tabs_content as the tab names)
23
-     * @param bool  $small_tabs
24
-     * @param bool  $tabs_content
25
-     * @return string the assembled html string containing the tabbed content for display.
26
-     * @throws EE_Error
27
-     */
28
-    public static function display($tabs_contents, $tabs_names = [], $small_tabs = true, $tabs_content = true)
29
-    {
16
+	/**
17
+	 * assembles and returns the html structure for tabs
18
+	 *
19
+	 * @static
20
+	 * @param array $tabs_contents an array of the content for each tab [required]
21
+	 * @param array $tabs_names    a numerically indexed array of names for each tab [optional]
22
+	 *                             - if this isn't included then we use the indexes for $tabs_content as the tab names)
23
+	 * @param bool  $small_tabs
24
+	 * @param bool  $tabs_content
25
+	 * @return string the assembled html string containing the tabbed content for display.
26
+	 * @throws EE_Error
27
+	 */
28
+	public static function display($tabs_contents, $tabs_names = [], $small_tabs = true, $tabs_content = true)
29
+	{
30 30
 
31
-        // first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston
32
-        if (! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
33
-            throw new EE_Error(
34
-                esc_html__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')
35
-            );
36
-        }
31
+		// first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston
32
+		if (! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
33
+			throw new EE_Error(
34
+				esc_html__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')
35
+			);
36
+		}
37 37
 
38
-        // make sure we've got incoming data setup properly
39
-        $tabs         = ! empty($tabs_names)
40
-            ? (array) $tabs_names
41
-            : array_keys((array) $tabs_contents);
42
-        $tabs_content = ! empty($tabs_names)
43
-            ? array_combine((array) $tabs_names, (array) $tabs_content)
44
-            : $tabs_contents;
38
+		// make sure we've got incoming data setup properly
39
+		$tabs         = ! empty($tabs_names)
40
+			? (array) $tabs_names
41
+			: array_keys((array) $tabs_contents);
42
+		$tabs_content = ! empty($tabs_names)
43
+			? array_combine((array) $tabs_names, (array) $tabs_content)
44
+			: $tabs_contents;
45 45
 
46
-        $tabs_html         = '';
47
-        $tabs_content_html = '';
46
+		$tabs_html         = '';
47
+		$tabs_content_html = '';
48 48
 
49
-        $index = 0;
50
-        foreach ($tabs as $tab) {
51
-            $active            = $index === 0;
52
-            $tabs_html         .= self::tab($tab, $active);
53
-            $tabs_content_html .= self::tab_content($tab, $tabs_content[ $tab ], $active);
54
-            $index++;
55
-        }
49
+		$index = 0;
50
+		foreach ($tabs as $tab) {
51
+			$active            = $index === 0;
52
+			$tabs_html         .= self::tab($tab, $active);
53
+			$tabs_content_html .= self::tab_content($tab, $tabs_content[ $tab ], $active);
54
+			$index++;
55
+		}
56 56
 
57
-        $tabs_class = $small_tabs ? ' ee-nav-tabs-small' : '';
57
+		$tabs_class = $small_tabs ? ' ee-nav-tabs-small' : '';
58 58
 
59
-        return "
59
+		return "
60 60
     <div class='ee-nav-tabs{$tabs_class}'>
61 61
         <h2 class='nav-tab-wrapper'>{$tabs_html}</h2>
62 62
         {$tabs_content_html}
63 63
     </div>
64 64
     ";
65
-    }
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * display_admin_nav_tabs
70
-     * this returns the properly formatted tab html for EE_Admin_Pages.
71
-     * We are expecting an array of tabs in the following format
72
-     * array(
73
-     *    'nav_tab_name' => array(
74
-     *        'url' => 'url for tab',
75
-     *        'link_text' => 'tab text',
76
-     *        'css_class' => 'tab class' //including the nav-tab-active class if its active
77
-     *    )
78
-     * )
79
-     *
80
-     * @access public
81
-     * @static
82
-     * @param string[][] $nav_tabs tab array for nav tabs
83
-     * @return string
84
-     * @throws EE_Error
85
-     */
86
-    public static function display_admin_nav_tabs(array $nav_tabs = [], string $page_slug = '')
87
-    {
88
-        if (empty($nav_tabs)) {
89
-            throw new EE_Error(
90
-                esc_html__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')
91
-            );
92
-        }
93
-        $tab_content = '';
94
-        $tab_count = 0;
95
-        foreach ($nav_tabs as $slug => $tab) {
96
-            $tab_count++;
97
-            $tab_content .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']);
98
-        }
99
-        $aria_label = esc_attr__('Secondary menu', 'event_espresso');
100
-        $css_class = "ee-nav-tabs--{$tab_count}";
101
-        $css_class .= $page_slug ? " ee-nav-tabs--$page_slug" : '';
102
-        return "
68
+	/**
69
+	 * display_admin_nav_tabs
70
+	 * this returns the properly formatted tab html for EE_Admin_Pages.
71
+	 * We are expecting an array of tabs in the following format
72
+	 * array(
73
+	 *    'nav_tab_name' => array(
74
+	 *        'url' => 'url for tab',
75
+	 *        'link_text' => 'tab text',
76
+	 *        'css_class' => 'tab class' //including the nav-tab-active class if its active
77
+	 *    )
78
+	 * )
79
+	 *
80
+	 * @access public
81
+	 * @static
82
+	 * @param string[][] $nav_tabs tab array for nav tabs
83
+	 * @return string
84
+	 * @throws EE_Error
85
+	 */
86
+	public static function display_admin_nav_tabs(array $nav_tabs = [], string $page_slug = '')
87
+	{
88
+		if (empty($nav_tabs)) {
89
+			throw new EE_Error(
90
+				esc_html__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')
91
+			);
92
+		}
93
+		$tab_content = '';
94
+		$tab_count = 0;
95
+		foreach ($nav_tabs as $slug => $tab) {
96
+			$tab_count++;
97
+			$tab_content .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']);
98
+		}
99
+		$aria_label = esc_attr__('Secondary menu', 'event_espresso');
100
+		$css_class = "ee-nav-tabs--{$tab_count}";
101
+		$css_class .= $page_slug ? " ee-nav-tabs--$page_slug" : '';
102
+		return "
103 103
         <nav class='nav-tab-wrapper wp-clearfix $css_class' aria-label='$aria_label'>
104 104
             $tab_content
105 105
         </nav>
106 106
         ";
107
-    }
107
+	}
108 108
 
109 109
 
110
-    /**
111
-     * this simply returns a single tab given a tab name & content
112
-     *
113
-     * @param string      $name      name of tab
114
-     * @param bool        $active    true=tab active, false=tab not active
115
-     * @param bool|string $nice_name if string given then this value will be used for the tab link text.
116
-     * @param bool|string $url       If url given then tabs will be generated linking to the url.
117
-     * @param bool|string $css       If string given then the generated tab will include that as the class.
118
-     * @return string          html for tab
119
-     */
120
-    private static function tab($name, $active = false, $nice_name = false, $url = false, $css = false)
121
-    {
122
-        $nice_name = $nice_name ?: esc_html(ucwords(str_replace(['_', '-'], ' ', $name)));
123
-        $name      = self::generateTabID($name);
124
-        $class     = $css ? ' ' . esc_attr($css) : '';
125
-        $class     .= $active ? ' nav-tab-active' : '';
126
-        $url       = $url ?: '#' . esc_attr($name);
127
-        return "
110
+	/**
111
+	 * this simply returns a single tab given a tab name & content
112
+	 *
113
+	 * @param string      $name      name of tab
114
+	 * @param bool        $active    true=tab active, false=tab not active
115
+	 * @param bool|string $nice_name if string given then this value will be used for the tab link text.
116
+	 * @param bool|string $url       If url given then tabs will be generated linking to the url.
117
+	 * @param bool|string $css       If string given then the generated tab will include that as the class.
118
+	 * @return string          html for tab
119
+	 */
120
+	private static function tab($name, $active = false, $nice_name = false, $url = false, $css = false)
121
+	{
122
+		$nice_name = $nice_name ?: esc_html(ucwords(str_replace(['_', '-'], ' ', $name)));
123
+		$name      = self::generateTabID($name);
124
+		$class     = $css ? ' ' . esc_attr($css) : '';
125
+		$class     .= $active ? ' nav-tab-active' : '';
126
+		$url       = $url ?: '#' . esc_attr($name);
127
+		return "
128 128
         <a class='nav-tab{$class}' rel='{$name}' href='{$url}'>
129 129
             $nice_name
130 130
         </a>
131 131
         ";
132
-    }
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * @param string $tab_name
137
-     * @return string
138
-     * @since   4.10.14.p
139
-     */
140
-    private static function generateTabID($tab_name)
141
-    {
142
-        return 'ee-tab-' . esc_attr(str_replace(' ', '-', $tab_name));
143
-    }
135
+	/**
136
+	 * @param string $tab_name
137
+	 * @return string
138
+	 * @since   4.10.14.p
139
+	 */
140
+	private static function generateTabID($tab_name)
141
+	{
142
+		return 'ee-tab-' . esc_attr(str_replace(' ', '-', $tab_name));
143
+	}
144 144
 
145 145
 
146
-    /**
147
-     * this just returns the properly formatted tab content for our tab box.
148
-     *
149
-     * @param string $name        name of tab (used for selector)
150
-     * @param string $tab_content content of tab
151
-     * @param bool   $active
152
-     * @return string html for content area
153
-     */
154
-    private static function tab_content($name, $tab_content, $active = false)
155
-    {
156
-        $class = $active ? '' : ' hidden';
157
-        $name  = self::generateTabID($name);
158
-        return "
146
+	/**
147
+	 * this just returns the properly formatted tab content for our tab box.
148
+	 *
149
+	 * @param string $name        name of tab (used for selector)
150
+	 * @param string $tab_content content of tab
151
+	 * @param bool   $active
152
+	 * @return string html for content area
153
+	 */
154
+	private static function tab_content($name, $tab_content, $active = false)
155
+	{
156
+		$class = $active ? '' : ' hidden';
157
+		$name  = self::generateTabID($name);
158
+		return "
159 159
     <div class='nav-tab-content{$class}' id='{$name}'>
160 160
         {$tab_content}
161 161
         <div style='clear:both'></div>
162 162
     </div>";
163
-    }
163
+	}
164 164
 
165 165
 
166 166
 
167
-    /** HORIZONTAL TEXT LINKS **/
167
+	/** HORIZONTAL TEXT LINKS **/
168 168
 
169
-    /**
170
-     * This will take in an array of link items and spit out a formatted list of links that can be used to navigate to
171
-     * items. There is a corresponding js file that can be loaded to dynamically display containers with the same id as
172
-     * the href -ref.
173
-     *
174
-     * @param string[] $item_array      formatted array of items.  Format:
175
-     *                                  array(
176
-     *                                  'label' => esc_html__('localized label displayed'),
177
-     *                                  'class' => 'class_for_item',
178
-     *                                  'href' => '#some_item_id', //url/bookmark for item.  If you include a bookmark
179
-     *                                  the js will used this to show the container div.
180
-     *                                  'title' => esc_html__('localized text for the title attribute of the link'),
181
-     *                                  'slug' => 'slug_used_for_reference'
182
-     *                                  )
183
-     * @param string   $container_class class used for main container
184
-     * @param string   $sep             you can add in what is used as a separator between each link (or leave blank for
185
-     *                                  none)
186
-     * @param string   $default         You can include a string for the item that will receive the "item_display" class
187
-     *                                  for the js.
188
-     * @return string                  a html snippet of of all the formatted link elements.
189
-     */
190
-    public static function tab_text_links(array $item_array, $container_class = '', $sep = '|', $default = '')
191
-    {
192
-        $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class);
193
-        if (! is_array($item_array) || empty($item_array)) {
194
-            return false; // get out we don't have even the basic thing we need!
195
-        }
169
+	/**
170
+	 * This will take in an array of link items and spit out a formatted list of links that can be used to navigate to
171
+	 * items. There is a corresponding js file that can be loaded to dynamically display containers with the same id as
172
+	 * the href -ref.
173
+	 *
174
+	 * @param string[] $item_array      formatted array of items.  Format:
175
+	 *                                  array(
176
+	 *                                  'label' => esc_html__('localized label displayed'),
177
+	 *                                  'class' => 'class_for_item',
178
+	 *                                  'href' => '#some_item_id', //url/bookmark for item.  If you include a bookmark
179
+	 *                                  the js will used this to show the container div.
180
+	 *                                  'title' => esc_html__('localized text for the title attribute of the link'),
181
+	 *                                  'slug' => 'slug_used_for_reference'
182
+	 *                                  )
183
+	 * @param string   $container_class class used for main container
184
+	 * @param string   $sep             you can add in what is used as a separator between each link (or leave blank for
185
+	 *                                  none)
186
+	 * @param string   $default         You can include a string for the item that will receive the "item_display" class
187
+	 *                                  for the js.
188
+	 * @return string                  a html snippet of of all the formatted link elements.
189
+	 */
190
+	public static function tab_text_links(array $item_array, $container_class = '', $sep = '|', $default = '')
191
+	{
192
+		$item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class);
193
+		if (! is_array($item_array) || empty($item_array)) {
194
+			return false; // get out we don't have even the basic thing we need!
195
+		}
196 196
 
197
-        $defaults        = [
198
-            'label' => esc_html__('Item', 'event_espresso'),
199
-            'class' => '',
200
-            'href'  => '',
201
-            'title' => esc_attr__('Link for Item', 'event_espresso'),
202
-            'slug'  => 'item_slug',
203
-        ];
204
-        $container_class = ! empty($container_class) ? ' ' . esc_attr($container_class) : '';
205
-        $list            = '';
206
-        $list_length     = count($item_array);
207
-        // if we're' adding separators, set $current to 1, otherwise set it to list length + 1
208
-        // then we'll increment $current while looping and only add separators if $current is < list length
209
-        // (if we aren't adding separators $current will always be > list length cuz it started at list length + 1)
210
-        $current = empty($sep) ? $list_length + 1 : 1;
211
-        foreach ($item_array as $item) {
212
-            $item          = wp_parse_args($item, $defaults);
213
-            $item['class'] .= $default === $item['slug'] ? ' item_display' : '';
214
-            $list          .= self::textLinkItem($item);
215
-            $list          .= $current < $list_length ? self::textLinkSeparator($sep) : '';
216
-            $current++;
217
-        }
197
+		$defaults        = [
198
+			'label' => esc_html__('Item', 'event_espresso'),
199
+			'class' => '',
200
+			'href'  => '',
201
+			'title' => esc_attr__('Link for Item', 'event_espresso'),
202
+			'slug'  => 'item_slug',
203
+		];
204
+		$container_class = ! empty($container_class) ? ' ' . esc_attr($container_class) : '';
205
+		$list            = '';
206
+		$list_length     = count($item_array);
207
+		// if we're' adding separators, set $current to 1, otherwise set it to list length + 1
208
+		// then we'll increment $current while looping and only add separators if $current is < list length
209
+		// (if we aren't adding separators $current will always be > list length cuz it started at list length + 1)
210
+		$current = empty($sep) ? $list_length + 1 : 1;
211
+		foreach ($item_array as $item) {
212
+			$item          = wp_parse_args($item, $defaults);
213
+			$item['class'] .= $default === $item['slug'] ? ' item_display' : '';
214
+			$list          .= self::textLinkItem($item);
215
+			$list          .= $current < $list_length ? self::textLinkSeparator($sep) : '';
216
+			$current++;
217
+		}
218 218
 
219
-        return "
219
+		return "
220 220
         <div class='ee-text-links{$container_class}'>{$list}</div>
221 221
         ";
222
-    }
222
+	}
223 223
 
224 224
 
225
-    /**
226
-     * @param string[] $item
227
-     * @return string
228
-     */
229
-    private static function textLinkItem(array $item)
230
-    {
231
-        $class = $item['class'] ? esc_attr($item['class']) : '';
232
-        $label = esc_html($item['label']);
233
-        $href  = $item['href'] ? esc_attr($item['href']) : '';
234
-        $icon  = $item['icon'] ?? '';
235
-        $title = esc_attr($item['title']);
236
-        $tag = $item['tag'] ?? 'a';
225
+	/**
226
+	 * @param string[] $item
227
+	 * @return string
228
+	 */
229
+	private static function textLinkItem(array $item)
230
+	{
231
+		$class = $item['class'] ? esc_attr($item['class']) : '';
232
+		$label = esc_html($item['label']);
233
+		$href  = $item['href'] ? esc_attr($item['href']) : '';
234
+		$icon  = $item['icon'] ?? '';
235
+		$title = esc_attr($item['title']);
236
+		$tag = $item['tag'] ?? 'a';
237 237
 
238 238
 
239
-        return ! empty($href)
240
-            ? "
239
+		return ! empty($href)
240
+			? "
241 241
             <{$tag} class='{$class} ee-text-link ee-aria-tooltip' href='#{$href}' aria-label='{$title}'>
242 242
                 {$icon}{$label}
243 243
             </{$tag}>
244 244
             "
245
-            : $label;
246
-    }
245
+			: $label;
246
+	}
247 247
 
248 248
 
249
-    /**
250
-     * @param string $separator
251
-     * @return string
252
-     * @since   4.10.14.p
253
-     */
254
-    private static function textLinkSeparator($separator)
255
-    {
256
-        $separator = esc_html($separator);
257
-        return "
249
+	/**
250
+	 * @param string $separator
251
+	 * @return string
252
+	 * @since   4.10.14.p
253
+	 */
254
+	private static function textLinkSeparator($separator)
255
+	{
256
+		$separator = esc_html($separator);
257
+		return "
258 258
         <span class='ee-text-link-sep'>{$separator}</span>
259 259
         ";
260
-    }
260
+	}
261 261
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Event_Question_Group.model.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -84,10 +84,10 @@
 block discarded – undo
84 84
         // this model is generally available for reading
85 85
         $path_to_event = 'Event';
86 86
 
87
-        $caps[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
88
-        $caps[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
89
-        $caps[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
90
-        $caps[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Event_Related_Protected(
87
+        $caps[EEM_Base::caps_read]       = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
88
+        $caps[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
89
+        $caps[EEM_Base::caps_edit]       = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
90
+        $caps[EEM_Base::caps_delete]     = new EE_Restriction_Generator_Event_Related_Protected(
91 91
             $path_to_event,
92 92
             EEM_Base::caps_edit
93 93
         );
Please login to merge, or discard this patch.
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -14,116 +14,116 @@
 block discarded – undo
14 14
  */
15 15
 class EEM_Event_Question_Group extends EEM_Base
16 16
 {
17
-    /**
18
-     * Name of the field indicating an event should use the question group for the primary attendee
19
-     */
20
-    const PRIMARY = 'EQG_primary';
17
+	/**
18
+	 * Name of the field indicating an event should use the question group for the primary attendee
19
+	 */
20
+	const PRIMARY = 'EQG_primary';
21 21
 
22
-    /**
23
-     * Name of hte field indicating an event should use the question group for additional attendees
24
-     */
25
-    const ADDITIONAL = 'EQG_additional';
22
+	/**
23
+	 * Name of hte field indicating an event should use the question group for additional attendees
24
+	 */
25
+	const ADDITIONAL = 'EQG_additional';
26 26
 
27 27
 
28
-    protected static ?EEM_Event_Question_Group $_instance = null;
28
+	protected static ?EEM_Event_Question_Group $_instance = null;
29 29
 
30 30
 
31
-    /**
32
-     * @param string|null $timezone
33
-     * @throws EE_Error
34
-     */
35
-    protected function __construct(?string $timezone = '')
36
-    {
37
-        $this->singular_item    = esc_html__('Event to Question Group Link', 'event_espresso');
38
-        $this->plural_item      = esc_html__('Event to Question Group Links', 'event_espresso');
39
-        $this->_tables          = [
40
-            'Event_Question_Group' => new EE_Primary_Table('esp_event_question_group', 'EQG_ID'),
41
-        ];
42
-        $this->_fields          = [
43
-            'Event_Question_Group' => [
44
-                'EQG_ID'         => new EE_Primary_Key_Int_Field(
45
-                    'EQG_ID',
46
-                    esc_html__('Event to Question Group Link ID', 'event_espresso')
47
-                ),
48
-                'EVT_ID'         => new EE_Foreign_Key_Int_Field(
49
-                    'EVT_ID',
50
-                    esc_html__('Event ID', 'event_espresso'),
51
-                    false,
52
-                    0,
53
-                    'Event'
54
-                ),
55
-                'QSG_ID'         => new EE_Foreign_Key_Int_Field(
56
-                    'QSG_ID',
57
-                    esc_html__('Question Group Id', 'event_espresso'),
58
-                    false,
59
-                    0,
60
-                    'Question_Group'
61
-                ),
62
-                'EQG_additional' => new EE_Boolean_Field(
63
-                    'EQG_additional',
64
-                    esc_html__(
65
-                        'Flag indicating question is only for additional attendees',
66
-                        'event_espresso'
67
-                    ),
68
-                    false,
69
-                    false
70
-                ),
71
-                'EQG_primary'    => new EE_Boolean_Field(
72
-                    'EQG_primary',
73
-                    esc_html__(
74
-                        'Flag indicating question is only for primary attendees',
75
-                        'event_espresso'
76
-                    ),
77
-                    false,
78
-                    false
79
-                ),
80
-            ],
81
-        ];
82
-        $this->_model_relations = [
83
-            'Event'          => new EE_Belongs_To_Relation(),
84
-            'Question_Group' => new EE_Belongs_To_Relation(),
85
-        ];
31
+	/**
32
+	 * @param string|null $timezone
33
+	 * @throws EE_Error
34
+	 */
35
+	protected function __construct(?string $timezone = '')
36
+	{
37
+		$this->singular_item    = esc_html__('Event to Question Group Link', 'event_espresso');
38
+		$this->plural_item      = esc_html__('Event to Question Group Links', 'event_espresso');
39
+		$this->_tables          = [
40
+			'Event_Question_Group' => new EE_Primary_Table('esp_event_question_group', 'EQG_ID'),
41
+		];
42
+		$this->_fields          = [
43
+			'Event_Question_Group' => [
44
+				'EQG_ID'         => new EE_Primary_Key_Int_Field(
45
+					'EQG_ID',
46
+					esc_html__('Event to Question Group Link ID', 'event_espresso')
47
+				),
48
+				'EVT_ID'         => new EE_Foreign_Key_Int_Field(
49
+					'EVT_ID',
50
+					esc_html__('Event ID', 'event_espresso'),
51
+					false,
52
+					0,
53
+					'Event'
54
+				),
55
+				'QSG_ID'         => new EE_Foreign_Key_Int_Field(
56
+					'QSG_ID',
57
+					esc_html__('Question Group Id', 'event_espresso'),
58
+					false,
59
+					0,
60
+					'Question_Group'
61
+				),
62
+				'EQG_additional' => new EE_Boolean_Field(
63
+					'EQG_additional',
64
+					esc_html__(
65
+						'Flag indicating question is only for additional attendees',
66
+						'event_espresso'
67
+					),
68
+					false,
69
+					false
70
+				),
71
+				'EQG_primary'    => new EE_Boolean_Field(
72
+					'EQG_primary',
73
+					esc_html__(
74
+						'Flag indicating question is only for primary attendees',
75
+						'event_espresso'
76
+					),
77
+					false,
78
+					false
79
+				),
80
+			],
81
+		];
82
+		$this->_model_relations = [
83
+			'Event'          => new EE_Belongs_To_Relation(),
84
+			'Question_Group' => new EE_Belongs_To_Relation(),
85
+		];
86 86
 
87
-        // this model is generally available for reading
88
-        $path_to_event = 'Event';
87
+		// this model is generally available for reading
88
+		$path_to_event = 'Event';
89 89
 
90
-        $caps[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
91
-        $caps[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
92
-        $caps[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
93
-        $caps[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Event_Related_Protected(
94
-            $path_to_event,
95
-            EEM_Base::caps_edit
96
-        );
97
-        $this->_cap_restriction_generators = $caps;
98
-        parent::__construct($timezone);
99
-    }
90
+		$caps[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
91
+		$caps[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
92
+		$caps[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
93
+		$caps[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Event_Related_Protected(
94
+			$path_to_event,
95
+			EEM_Base::caps_edit
96
+		);
97
+		$this->_cap_restriction_generators = $caps;
98
+		parent::__construct($timezone);
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * Decides whether to use the 'EQG_primary' or newer 'EQG_additional' for use in queries, based on whether
104
-     * this is concerning primary attendees or additional attendees.
105
-     * If 1, true, or "primary" is passed in, returns EQG_primary. If 0, false, or "additional" is passed in, returns
106
-     * EQG_additional.
107
-     *
108
-     * @param string|boolean|int $context
109
-     * @return string
110
-     * @since 4.10.0.p
111
-     */
112
-    public function fieldNameForContext($context): string
113
-    {
114
-        // Basically do a strict switch statement.
115
-        switch (true) {
116
-            case $context === 'additional':
117
-            case $context === false:
118
-            case $context === 0:
119
-                $field_name = EEM_Event_Question_Group::ADDITIONAL;
120
-                break;
121
-            case $context === 'primary':
122
-            case $context === true:
123
-            case $context === 1:
124
-            default:
125
-                $field_name = EEM_Event_Question_Group::PRIMARY;
126
-        }
127
-        return apply_filters('FHEE__EEM_Event_Question_Group__fieldNameForContext', $field_name, $context);
128
-    }
102
+	/**
103
+	 * Decides whether to use the 'EQG_primary' or newer 'EQG_additional' for use in queries, based on whether
104
+	 * this is concerning primary attendees or additional attendees.
105
+	 * If 1, true, or "primary" is passed in, returns EQG_primary. If 0, false, or "additional" is passed in, returns
106
+	 * EQG_additional.
107
+	 *
108
+	 * @param string|boolean|int $context
109
+	 * @return string
110
+	 * @since 4.10.0.p
111
+	 */
112
+	public function fieldNameForContext($context): string
113
+	{
114
+		// Basically do a strict switch statement.
115
+		switch (true) {
116
+			case $context === 'additional':
117
+			case $context === false:
118
+			case $context === 0:
119
+				$field_name = EEM_Event_Question_Group::ADDITIONAL;
120
+				break;
121
+			case $context === 'primary':
122
+			case $context === true:
123
+			case $context === 1:
124
+			default:
125
+				$field_name = EEM_Event_Question_Group::PRIMARY;
126
+		}
127
+		return apply_filters('FHEE__EEM_Event_Question_Group__fieldNameForContext', $field_name, $context);
128
+	}
129 129
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Default_Where_Conditions.strategy.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         $qualified_where_conditions = [];
134 134
         foreach ($where_conditions as $key => $value) {
135 135
             if ($this->isOrHasQueryOperator($key)) {
136
-                $qualified_where_conditions[ $key ] =
136
+                $qualified_where_conditions[$key] =
137 137
                     $this->prepare_where_conditions_for_querying(
138 138
                         $value,
139 139
                         $model_relation_chain
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         $value
184 184
     ): array {
185 185
         $model_relation_chain = $model_relation_chain !== ''
186
-            ? rtrim($model_relation_chain, '.') . '.'
186
+            ? rtrim($model_relation_chain, '.').'.'
187 187
             : $model_relation_chain;
188 188
         // check for the current user id place holder, and if present change it
189 189
         if ($value === self::current_user_placeholder) {
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         }
192 192
         // check for user field placeholder
193 193
         if ($key === self::user_field_name_placeholder) {
194
-            if (! $this->_model->wp_user_field_name()) {
194
+            if ( ! $this->_model->wp_user_field_name()) {
195 195
                 throw new EE_Error(
196 196
                     sprintf(
197 197
                         esc_html__(
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
             }
205 205
             $key = $this->_model->wp_user_field_name();
206 206
         }
207
-        $qualified_where_conditions[ $model_relation_chain . $key ] = $value;
207
+        $qualified_where_conditions[$model_relation_chain.$key] = $value;
208 208
         return $qualified_where_conditions;
209 209
     }
210 210
 }
Please login to merge, or discard this patch.
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -15,195 +15,195 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Default_Where_Conditions
17 17
 {
18
-    /**
19
-     * This const can be used in EE_Default_Where_Conditions values, and at the
20
-     * time of querying it will be replaced with the current user's ID (because
21
-     * we don't want to use the current user's ID at time of initializing the
22
-     * models because it's too early)
23
-     */
24
-    const current_user_placeholder = '%$current_user_placeholder_should_be_replaced_automatically$%';
25
-
26
-    /**
27
-     * This const can be used in EE_Default_Where_Conditions where parameters
28
-     * as the name of the user field. When we are actually generating the where
29
-     * conditions it will be replaced with the model's wp user field name
30
-     */
31
-    const user_field_name_placeholder = '%$user_field_name_placeholder$%';
32
-
33
-    /**
34
-     * Model for which this strategy find default where conditions
35
-     *
36
-     * @var EEM_Base
37
-     */
38
-    protected $_model;
39
-
40
-    /**
41
-     * Where conditions specified on construction
42
-     *
43
-     * @var array
44
-     */
45
-    protected $_where_conditions_provided = [];
46
-
47
-
48
-    /**
49
-     * Custom where conditions. Model relation chains will be automatically
50
-     * added onto any field names
51
-     *
52
-     * @param array $custom_where_conditions
53
-     */
54
-    public function __construct(array $custom_where_conditions = [])
55
-    {
56
-        $this->_where_conditions_provided = $custom_where_conditions;
57
-    }
58
-
59
-
60
-    /**
61
-     * finalizes construction of the strategy for use in getting default where
62
-     * conditions for querying of the model.
63
-     *
64
-     * @param EEM_Base $model
65
-     */
66
-    public function _finalize_construct(EEM_Base $model)
67
-    {
68
-        $this->_model = $model;
69
-    }
70
-
71
-
72
-    /**
73
-     * Returns the where conditions explicitly passed in the constructor
74
-     *
75
-     * @return array
76
-     */
77
-    public function get_where_conditions_provided(): array
78
-    {
79
-        return $this->_where_conditions_provided;
80
-    }
81
-
82
-
83
-    /**
84
-     * Gets the where conditions to be added onto the query
85
-     *
86
-     * @param string $model_relation_chain
87
-     * @return array
88
-     * @throws EE_Error
89
-     * @throws EE_Error
90
-     * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
91
-     */
92
-    public function get_default_where_conditions(
93
-        string $model_relation_chain = ''
94
-    ): array {
95
-        return $this->prepare_where_conditions_for_querying(
96
-            array_merge(
97
-                $this->_get_default_where_conditions(),
98
-                $this->get_where_conditions_provided()
99
-            ),
100
-            $model_relation_chain
101
-        );
102
-    }
103
-
104
-
105
-    /**
106
-     * Gets the default where conditions that are specific to this child of
107
-     * EE_Default_Where_Conditions. Adding model relation chains is handled by
108
-     * the public method get_default_where_conditions
109
-     *
110
-     * @return array
111
-     */
112
-    protected function _get_default_where_conditions(): array
113
-    {
114
-        return [];
115
-    }
116
-
117
-
118
-    /**
119
-     * Takes the default query parameters, and traverses them, adding the model
120
-     * relation chain onto them (intelligently doesn't do that to logic query
121
-     * params like NOT, OR, and AND)
122
-     *
123
-     * @param array  $where_conditions
124
-     * @param string $model_relation_chain
125
-     * @return array
126
-     * @throws EE_Error
127
-     */
128
-    public function prepare_where_conditions_for_querying(
129
-        array $where_conditions = [],
130
-        string $model_relation_chain = ''
131
-    ): array {
132
-        $qualified_where_conditions = [];
133
-        foreach ($where_conditions as $key => $value) {
134
-            if ($this->isOrHasQueryOperator($key)) {
135
-                $qualified_where_conditions[ $key ] =
136
-                    $this->prepare_where_conditions_for_querying(
137
-                        $value,
138
-                        $model_relation_chain
139
-                    );
140
-            } else {
141
-                $qualified_where_conditions =
142
-                    $this->prepare_where_condition(
143
-                        $qualified_where_conditions,
144
-                        $model_relation_chain,
145
-                        $key,
146
-                        $value
147
-                    );
148
-            }
149
-        }
150
-        return $qualified_where_conditions;
151
-    }
152
-
153
-
154
-    /**
155
-     * @param string $query_string
156
-     * @return bool
157
-     */
158
-    private function isOrHasQueryOperator(string $query_string): bool
159
-    {
160
-        return in_array($query_string, ['OR', 'AND', 'NOT'])
161
-               || strpos($query_string, 'OR*') !== false
162
-               || strpos($query_string, 'AND*') !== false
163
-               || strpos($query_string, 'NOT*') !== false;
164
-    }
165
-
166
-
167
-    /**
168
-     * ensures relation name is fully qualified
169
-     * and swaps placeholders for expected values
170
-     *
171
-     * @param array  $qualified_where_conditions
172
-     * @param string $model_relation_chain
173
-     * @param string $key
174
-     * @param mixed $value
175
-     * @return array
176
-     * @throws EE_Error
177
-     */
178
-    private function prepare_where_condition(
179
-        array $qualified_where_conditions,
180
-        string $model_relation_chain,
181
-        string $key,
182
-        $value
183
-    ): array {
184
-        $model_relation_chain = $model_relation_chain !== ''
185
-            ? rtrim($model_relation_chain, '.') . '.'
186
-            : $model_relation_chain;
187
-        // check for the current user id place holder, and if present change it
188
-        if ($value === self::current_user_placeholder) {
189
-            $value = get_current_user_id();
190
-        }
191
-        // check for user field placeholder
192
-        if ($key === self::user_field_name_placeholder) {
193
-            if (! $this->_model->wp_user_field_name()) {
194
-                throw new EE_Error(
195
-                    sprintf(
196
-                        esc_html__(
197
-                            'There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model',
198
-                            'event_espresso'
199
-                        ),
200
-                        $this->_model->get_this_model_name()
201
-                    )
202
-                );
203
-            }
204
-            $key = $this->_model->wp_user_field_name();
205
-        }
206
-        $qualified_where_conditions[ $model_relation_chain . $key ] = $value;
207
-        return $qualified_where_conditions;
208
-    }
18
+	/**
19
+	 * This const can be used in EE_Default_Where_Conditions values, and at the
20
+	 * time of querying it will be replaced with the current user's ID (because
21
+	 * we don't want to use the current user's ID at time of initializing the
22
+	 * models because it's too early)
23
+	 */
24
+	const current_user_placeholder = '%$current_user_placeholder_should_be_replaced_automatically$%';
25
+
26
+	/**
27
+	 * This const can be used in EE_Default_Where_Conditions where parameters
28
+	 * as the name of the user field. When we are actually generating the where
29
+	 * conditions it will be replaced with the model's wp user field name
30
+	 */
31
+	const user_field_name_placeholder = '%$user_field_name_placeholder$%';
32
+
33
+	/**
34
+	 * Model for which this strategy find default where conditions
35
+	 *
36
+	 * @var EEM_Base
37
+	 */
38
+	protected $_model;
39
+
40
+	/**
41
+	 * Where conditions specified on construction
42
+	 *
43
+	 * @var array
44
+	 */
45
+	protected $_where_conditions_provided = [];
46
+
47
+
48
+	/**
49
+	 * Custom where conditions. Model relation chains will be automatically
50
+	 * added onto any field names
51
+	 *
52
+	 * @param array $custom_where_conditions
53
+	 */
54
+	public function __construct(array $custom_where_conditions = [])
55
+	{
56
+		$this->_where_conditions_provided = $custom_where_conditions;
57
+	}
58
+
59
+
60
+	/**
61
+	 * finalizes construction of the strategy for use in getting default where
62
+	 * conditions for querying of the model.
63
+	 *
64
+	 * @param EEM_Base $model
65
+	 */
66
+	public function _finalize_construct(EEM_Base $model)
67
+	{
68
+		$this->_model = $model;
69
+	}
70
+
71
+
72
+	/**
73
+	 * Returns the where conditions explicitly passed in the constructor
74
+	 *
75
+	 * @return array
76
+	 */
77
+	public function get_where_conditions_provided(): array
78
+	{
79
+		return $this->_where_conditions_provided;
80
+	}
81
+
82
+
83
+	/**
84
+	 * Gets the where conditions to be added onto the query
85
+	 *
86
+	 * @param string $model_relation_chain
87
+	 * @return array
88
+	 * @throws EE_Error
89
+	 * @throws EE_Error
90
+	 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
91
+	 */
92
+	public function get_default_where_conditions(
93
+		string $model_relation_chain = ''
94
+	): array {
95
+		return $this->prepare_where_conditions_for_querying(
96
+			array_merge(
97
+				$this->_get_default_where_conditions(),
98
+				$this->get_where_conditions_provided()
99
+			),
100
+			$model_relation_chain
101
+		);
102
+	}
103
+
104
+
105
+	/**
106
+	 * Gets the default where conditions that are specific to this child of
107
+	 * EE_Default_Where_Conditions. Adding model relation chains is handled by
108
+	 * the public method get_default_where_conditions
109
+	 *
110
+	 * @return array
111
+	 */
112
+	protected function _get_default_where_conditions(): array
113
+	{
114
+		return [];
115
+	}
116
+
117
+
118
+	/**
119
+	 * Takes the default query parameters, and traverses them, adding the model
120
+	 * relation chain onto them (intelligently doesn't do that to logic query
121
+	 * params like NOT, OR, and AND)
122
+	 *
123
+	 * @param array  $where_conditions
124
+	 * @param string $model_relation_chain
125
+	 * @return array
126
+	 * @throws EE_Error
127
+	 */
128
+	public function prepare_where_conditions_for_querying(
129
+		array $where_conditions = [],
130
+		string $model_relation_chain = ''
131
+	): array {
132
+		$qualified_where_conditions = [];
133
+		foreach ($where_conditions as $key => $value) {
134
+			if ($this->isOrHasQueryOperator($key)) {
135
+				$qualified_where_conditions[ $key ] =
136
+					$this->prepare_where_conditions_for_querying(
137
+						$value,
138
+						$model_relation_chain
139
+					);
140
+			} else {
141
+				$qualified_where_conditions =
142
+					$this->prepare_where_condition(
143
+						$qualified_where_conditions,
144
+						$model_relation_chain,
145
+						$key,
146
+						$value
147
+					);
148
+			}
149
+		}
150
+		return $qualified_where_conditions;
151
+	}
152
+
153
+
154
+	/**
155
+	 * @param string $query_string
156
+	 * @return bool
157
+	 */
158
+	private function isOrHasQueryOperator(string $query_string): bool
159
+	{
160
+		return in_array($query_string, ['OR', 'AND', 'NOT'])
161
+			   || strpos($query_string, 'OR*') !== false
162
+			   || strpos($query_string, 'AND*') !== false
163
+			   || strpos($query_string, 'NOT*') !== false;
164
+	}
165
+
166
+
167
+	/**
168
+	 * ensures relation name is fully qualified
169
+	 * and swaps placeholders for expected values
170
+	 *
171
+	 * @param array  $qualified_where_conditions
172
+	 * @param string $model_relation_chain
173
+	 * @param string $key
174
+	 * @param mixed $value
175
+	 * @return array
176
+	 * @throws EE_Error
177
+	 */
178
+	private function prepare_where_condition(
179
+		array $qualified_where_conditions,
180
+		string $model_relation_chain,
181
+		string $key,
182
+		$value
183
+	): array {
184
+		$model_relation_chain = $model_relation_chain !== ''
185
+			? rtrim($model_relation_chain, '.') . '.'
186
+			: $model_relation_chain;
187
+		// check for the current user id place holder, and if present change it
188
+		if ($value === self::current_user_placeholder) {
189
+			$value = get_current_user_id();
190
+		}
191
+		// check for user field placeholder
192
+		if ($key === self::user_field_name_placeholder) {
193
+			if (! $this->_model->wp_user_field_name()) {
194
+				throw new EE_Error(
195
+					sprintf(
196
+						esc_html__(
197
+							'There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model',
198
+							'event_espresso'
199
+						),
200
+						$this->_model->get_this_model_name()
201
+					)
202
+				);
203
+			}
204
+			$key = $this->_model->wp_user_field_name();
205
+		}
206
+		$qualified_where_conditions[ $model_relation_chain . $key ] = $value;
207
+		return $qualified_where_conditions;
208
+	}
209 209
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Boolean_Field.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -2,62 +2,62 @@
 block discarded – undo
2 2
 
3 3
 class EE_Boolean_Field extends EE_Integer_Field
4 4
 {
5
-    /**
6
-     * @param string $table_column
7
-     * @param string $nicename
8
-     * @param bool   $nullable
9
-     * @param null   $default_value
10
-     */
11
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
12
-    {
13
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
14
-        $this->setSchemaType('boolean');
15
-    }
5
+	/**
6
+	 * @param string $table_column
7
+	 * @param string $nicename
8
+	 * @param bool   $nullable
9
+	 * @param null   $default_value
10
+	 */
11
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
12
+	{
13
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
14
+		$this->setSchemaType('boolean');
15
+	}
16 16
 
17
-    /**
18
-     * Double-checks the value being returned is an boolean.
19
-     * @since 4.9.74.p
20
-     * @param mixed $value_of_field_on_model_object
21
-     * @return boolean
22
-     */
23
-    public function prepare_for_get($value_of_field_on_model_object)
24
-    {
25
-        return (bool) parent::prepare_for_get($value_of_field_on_model_object);
26
-    }
17
+	/**
18
+	 * Double-checks the value being returned is an boolean.
19
+	 * @since 4.9.74.p
20
+	 * @param mixed $value_of_field_on_model_object
21
+	 * @return boolean
22
+	 */
23
+	public function prepare_for_get($value_of_field_on_model_object)
24
+	{
25
+		return (bool) parent::prepare_for_get($value_of_field_on_model_object);
26
+	}
27 27
 
28
-    /**
29
-     * @since 4.9.74.p
30
-     * @param $value_inputted_for_field_on_model_object
31
-     * @return boolean
32
-     */
33
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
34
-    {
35
-        return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN);
36
-    }
28
+	/**
29
+	 * @since 4.9.74.p
30
+	 * @param $value_inputted_for_field_on_model_object
31
+	 * @return boolean
32
+	 */
33
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
34
+	{
35
+		return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN);
36
+	}
37 37
 
38
-    /**
39
-     * Make sure we're returning booleans
40
-     *
41
-     * @param string $value_inputted_for_field_on_model_object
42
-     * @return boolean
43
-     */
44
-    public function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
45
-    {
46
-        return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN);
47
-    }
38
+	/**
39
+	 * Make sure we're returning booleans
40
+	 *
41
+	 * @param string $value_inputted_for_field_on_model_object
42
+	 * @return boolean
43
+	 */
44
+	public function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
45
+	{
46
+		return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN);
47
+	}
48 48
 
49
-    /**
50
-     * Gets a nice Yes/No value for this field
51
-     *
52
-     * @param boolean $value_on_field_to_be_outputted
53
-     * @return string Yes or No
54
-     */
55
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted)
56
-    {
57
-        return apply_filters(
58
-            'FHEE__EE_Boolean_Field__prepare_for_pretty_echoing__return',
59
-            $value_on_field_to_be_outputted ? esc_html__('Yes', 'event_espresso') : esc_html__('No', 'event_espresso'),
60
-            $value_on_field_to_be_outputted
61
-        );
62
-    }
49
+	/**
50
+	 * Gets a nice Yes/No value for this field
51
+	 *
52
+	 * @param boolean $value_on_field_to_be_outputted
53
+	 * @return string Yes or No
54
+	 */
55
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted)
56
+	{
57
+		return apply_filters(
58
+			'FHEE__EE_Boolean_Field__prepare_for_pretty_echoing__return',
59
+			$value_on_field_to_be_outputted ? esc_html__('Yes', 'event_espresso') : esc_html__('No', 'event_espresso'),
60
+			$value_on_field_to_be_outputted
61
+		);
62
+	}
63 63
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Currency.model.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
             'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
61 61
         ];
62 62
         // this model is generally available for reading
63
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
63
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
64 64
 
65 65
         parent::__construct($timezone);
66 66
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     public function get_all_active($query_params = [])
78 78
     {
79 79
         $query_params[0]['CUR_active'] = true;
80
-        if (! isset($query_params['order_by'])) {
80
+        if ( ! isset($query_params['order_by'])) {
81 81
             $query_params['order_by'] = ['CUR_code' => 'ASC', 'CUR_single' => 'ASC'];
82 82
         }
83 83
         return $this->get_all($query_params);
Please login to merge, or discard this patch.
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -9,109 +9,109 @@
 block discarded – undo
9 9
  */
10 10
 class EEM_Currency extends EEM_Base
11 11
 {
12
-    protected static ?EEM_Currency $_instance = null;
12
+	protected static ?EEM_Currency $_instance = null;
13 13
 
14 14
 
15
-    /**
16
-     * @param string|null $timezone
17
-     * @throws EE_Error
18
-     */
19
-    protected function __construct(?string $timezone = '')
20
-    {
21
-        $this->singular_item    = esc_html__('Currency', 'event_espresso');
22
-        $this->plural_item      = esc_html__('Currencies', 'event_espresso');
23
-        $this->_tables          = [
24
-            'Currency' => new EE_Primary_Table('esp_currency', 'CUR_code'),
25
-        ];
26
-        $this->_fields          = [
27
-            'Currency' => [
28
-                'CUR_code'    => new EE_Primary_Key_String_Field(
29
-                    'CUR_code',
30
-                    esc_html__('Currency Code', 'event_espresso')
31
-                )
32
-                ,
33
-                'CUR_single'  => new EE_Plain_Text_Field(
34
-                    'CUR_single',
35
-                    esc_html__('Currency Name Singular', 'event_espresso'),
36
-                    false
37
-                ),
38
-                'CUR_plural'  => new EE_Plain_Text_Field(
39
-                    'CUR_plural',
40
-                    esc_html__('Currency Name Plural', 'event_espresso'),
41
-                    false
42
-                ),
43
-                'CUR_sign'    => new EE_Plain_Text_Field(
44
-                    'CUR_sign',
45
-                    esc_html__('Currency Sign', 'event_espresso'),
46
-                    false
47
-                ),
48
-                'CUR_dec_plc' => new EE_Integer_Field(
49
-                    'CUR_dec_plc',
50
-                    esc_html__('Currency Decimal Places', 'event_espresso'),
51
-                    false,
52
-                    2
53
-                ),
54
-                'CUR_active'  => new EE_Boolean_Field(
55
-                    'CUR_active',
56
-                    esc_html__('Active?', 'event_espresso'),
57
-                    false,
58
-                    true
59
-                ),
60
-            ],
61
-        ];
62
-        $this->_model_relations = [
63
-            'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
64
-        ];
65
-        // this model is generally available for reading
66
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
15
+	/**
16
+	 * @param string|null $timezone
17
+	 * @throws EE_Error
18
+	 */
19
+	protected function __construct(?string $timezone = '')
20
+	{
21
+		$this->singular_item    = esc_html__('Currency', 'event_espresso');
22
+		$this->plural_item      = esc_html__('Currencies', 'event_espresso');
23
+		$this->_tables          = [
24
+			'Currency' => new EE_Primary_Table('esp_currency', 'CUR_code'),
25
+		];
26
+		$this->_fields          = [
27
+			'Currency' => [
28
+				'CUR_code'    => new EE_Primary_Key_String_Field(
29
+					'CUR_code',
30
+					esc_html__('Currency Code', 'event_espresso')
31
+				)
32
+				,
33
+				'CUR_single'  => new EE_Plain_Text_Field(
34
+					'CUR_single',
35
+					esc_html__('Currency Name Singular', 'event_espresso'),
36
+					false
37
+				),
38
+				'CUR_plural'  => new EE_Plain_Text_Field(
39
+					'CUR_plural',
40
+					esc_html__('Currency Name Plural', 'event_espresso'),
41
+					false
42
+				),
43
+				'CUR_sign'    => new EE_Plain_Text_Field(
44
+					'CUR_sign',
45
+					esc_html__('Currency Sign', 'event_espresso'),
46
+					false
47
+				),
48
+				'CUR_dec_plc' => new EE_Integer_Field(
49
+					'CUR_dec_plc',
50
+					esc_html__('Currency Decimal Places', 'event_espresso'),
51
+					false,
52
+					2
53
+				),
54
+				'CUR_active'  => new EE_Boolean_Field(
55
+					'CUR_active',
56
+					esc_html__('Active?', 'event_espresso'),
57
+					false,
58
+					true
59
+				),
60
+			],
61
+		];
62
+		$this->_model_relations = [
63
+			'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
64
+		];
65
+		// this model is generally available for reading
66
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
67 67
 
68
-        parent::__construct($timezone);
69
-    }
68
+		parent::__construct($timezone);
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * Gets all the active currencies, and orders them by their singular name, and then their code
74
-     * (may be overridden)
75
-     *
76
-     * @param array $query_params
77
-     * @return EE_Currency[]
78
-     * @throws EE_Error
79
-     * @throws ReflectionException
80
-     * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
81
-     */
82
-    public function get_all_active($query_params = [])
83
-    {
84
-        $query_params[0]['CUR_active'] = true;
85
-        if (! isset($query_params['order_by'])) {
86
-            $query_params['order_by'] = ['CUR_code' => 'ASC', 'CUR_single' => 'ASC'];
87
-        }
88
-        return $this->get_all($query_params);
89
-    }
72
+	/**
73
+	 * Gets all the active currencies, and orders them by their singular name, and then their code
74
+	 * (may be overridden)
75
+	 *
76
+	 * @param array $query_params
77
+	 * @return EE_Currency[]
78
+	 * @throws EE_Error
79
+	 * @throws ReflectionException
80
+	 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
81
+	 */
82
+	public function get_all_active($query_params = [])
83
+	{
84
+		$query_params[0]['CUR_active'] = true;
85
+		if (! isset($query_params['order_by'])) {
86
+			$query_params['order_by'] = ['CUR_code' => 'ASC', 'CUR_single' => 'ASC'];
87
+		}
88
+		return $this->get_all($query_params);
89
+	}
90 90
 
91 91
 
92
-    /**
93
-     * Gets all the currencies which can be used by that payment method type
94
-     *
95
-     * @param EE_PMT_Base $payment_method_type
96
-     * @return EE_Currency[]
97
-     * @throws EE_Error
98
-     * @throws ReflectionException
99
-     */
100
-    public function get_all_currencies_usable_by($payment_method_type)
101
-    {
102
-        if (
103
-            $payment_method_type instanceof EE_PMT_Base
104
-            && $payment_method_type->get_gateway()
105
-        ) {
106
-            $currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
107
-        } else {
108
-            $currencies_supported = EE_Gateway::all_currencies_supported;
109
-        }
110
-        if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
111
-            $currencies = $this->get_all_active();
112
-        } else {
113
-            $currencies = $this->get_all_active([['CUR_code' => ['IN', $currencies_supported]]]);
114
-        }
115
-        return $currencies;
116
-    }
92
+	/**
93
+	 * Gets all the currencies which can be used by that payment method type
94
+	 *
95
+	 * @param EE_PMT_Base $payment_method_type
96
+	 * @return EE_Currency[]
97
+	 * @throws EE_Error
98
+	 * @throws ReflectionException
99
+	 */
100
+	public function get_all_currencies_usable_by($payment_method_type)
101
+	{
102
+		if (
103
+			$payment_method_type instanceof EE_PMT_Base
104
+			&& $payment_method_type->get_gateway()
105
+		) {
106
+			$currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
107
+		} else {
108
+			$currencies_supported = EE_Gateway::all_currencies_supported;
109
+		}
110
+		if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
111
+			$currencies = $this->get_all_active();
112
+		} else {
113
+			$currencies = $this->get_all_active([['CUR_code' => ['IN', $currencies_supported]]]);
114
+		}
115
+		return $currencies;
116
+	}
117 117
 }
Please login to merge, or discard this patch.