Test Failed
Pull Request — master (#2551)
by Devin
04:51
created

admin-pages.php ➔ give_add_display_page_states()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 12
nc 4
nop 2
dl 0
loc 18
rs 9.2
c 0
b 0
f 0
ccs 0
cts 0
cp 0
crap 20
1
<?php
2
/**
3
 * Admin Pages
4
 *
5
 * @package     Give
6
 * @subpackage  Admin/Pages
7
 * @copyright   Copyright (c) 2016, WordImpress
8
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
9
 * @since       1.0
10
 */
11
12
// Exit if accessed directly.
13 1
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * Creates the admin submenu pages under the Give menu and assigns their
19
 * links to global variables
20
 *
21
 * @since 1.0
22
 *
23
 * @global $give_settings_page
24
 * @global $give_payments_page
25
 * @global $give_reports_page
26
 * @global $give_add_ons_page
27
 * @global $give_donors_page
28
 *
29
 * @return void
30
 */
31
function give_add_options_links() {
32
	global $give_settings_page, $give_payments_page, $give_reports_page, $give_add_ons_page, $give_donors_page, $give_tools_page;
33
34
	//Payments
35
	$give_payment       = get_post_type_object( 'give_payment' );
36
	$give_payments_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page' );
37
38
	//Donors
39
	$give_donors_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donors', 'give' ), esc_html__( 'Donors', 'give' ), 'view_give_reports', 'give-donors', 'give_donors_page' );
40
41
	//Reports`
42
	$give_reports_page = add_submenu_page(
43
		'edit.php?post_type=give_forms',
44
		esc_html__( 'Donation Reports', 'give' ),
45
		esc_html__( 'Reports', 'give' ),
46
		'view_give_reports',
47
		'give-reports',
48
		array(
49
			Give()->give_settings,
50
			'output',
51
		)
52
	);
53
54
	//Settings
55
	$give_settings_page = add_submenu_page(
56 1
		'edit.php?post_type=give_forms',
57
		esc_html__( 'Give Settings', 'give' ),
58
		esc_html__( 'Settings', 'give' ),
59
		'manage_give_settings',
60
		'give-settings',
61
		array(
62
			Give()->give_settings,
63
			'output',
64
		)
65
	);
66
67
	//Tools.
68
	$give_tools_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Tools', 'give' ), esc_html__( 'Tools', 'give' ), 'manage_give_settings', 'give-tools', array(
69
		Give()->give_settings,
70
		'output'
0 ignored issues
show
introduced by
Comma required after last value in array declaration
Loading history...
71
	) );
72
73 2
	//Add-ons
74
	$give_add_ons_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Add-ons', 'give' ), esc_html__( 'Add-ons', 'give' ), 'install_plugins', 'give-addons', 'give_add_ons_page' );
75 2
}
76 2
77 2
add_action( 'admin_menu', 'give_add_options_links', 10 );
78 2
79 2
/**
80 2
 *  Determines whether the current admin page is a Give admin page.
81 2
 *
82
 *  Only works after the `wp_loaded` hook, & most effective
83
 *  starting on `admin_menu` hook.
84 2
 *
85
 * @since 1.0
86
 *
87
 * @param string $passed_page Optional. Main page's slug
88
 * @param string $passed_view Optional. Page view ( ex: `edit` or `delete` )
89
 *
90
 * @return bool True if Give admin page.
91
 */
92
function give_is_admin_page( $passed_page = '', $passed_view = '' ) {
93
94
	global $pagenow, $typenow;
95
96
	$found     = false;
97
	$post_type = isset( $_GET['post_type'] ) ? strtolower( $_GET['post_type'] ) : false;
0 ignored issues
show
introduced by
Detected access of super global var $_GET, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_GET
Loading history...
98
	$action    = isset( $_GET['action'] ) ? strtolower( $_GET['action'] ) : false;
0 ignored issues
show
introduced by
Detected access of super global var $_GET, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_GET
Loading history...
99
	$taxonomy  = isset( $_GET['taxonomy'] ) ? strtolower( $_GET['taxonomy'] ) : false;
0 ignored issues
show
introduced by
Detected access of super global var $_GET, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_GET
Loading history...
100
	$page      = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
0 ignored issues
show
introduced by
Detected access of super global var $_GET, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_GET
Loading history...
101
	$view      = isset( $_GET['view'] ) ? strtolower( $_GET['view'] ) : false;
0 ignored issues
show
introduced by
Detected access of super global var $_GET, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_GET
Loading history...
102
	$tab       = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false;
0 ignored issues
show
introduced by
Detected access of super global var $_GET, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_GET
Loading history...
103
104
	switch ( $passed_page ) {
105
		case 'give_forms':
106
			switch ( $passed_view ) {
107
				case 'list-table':
108 2
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
109
						$found = true;
110
					}
111
					break;
112 View Code Duplication
				case 'edit':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
113
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post.php' ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
114
						$found = true;
115
					}
116
					break;
117 View Code Duplication
				case 'new':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
118
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post-new.php' ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
119
						$found = true;
120
					}
121
					break;
122
				default:
123
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) || 'give_forms' === $post_type || ( 'post-new.php' == $pagenow && 'give_forms' === $post_type ) ) {
124
						$found = true;
125
					}
126
					break;
127
			}
128 2
			break;
129 View Code Duplication
		case 'categories':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
130
			switch ( $passed_view ) {
131
				case 'list-table':
132
				case 'new':
133
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
134
						$found = true;
135
					}
136
					break;
137
				case 'edit':
138
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
139
						$found = true;
140
					}
141
					break;
142
				default:
143
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
144
						$found = true;
145
					}
146
					break;
147
			}
148 2
			break;
149 View Code Duplication
		case 'tags':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
150
			switch ( $passed_view ) {
151
				case 'list-table':
152
				case 'new':
153
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
154
						$found = true;
155
					}
156
					break;
157
				case 'edit':
158
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
159
						$found = true;
160
					}
161
					break;
162
				default:
163
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
164
						$found = true;
165
					}
166
					break;
167 2
			}
168
			break;
169
		case 'payments':
170
			switch ( $passed_view ) {
171
				case 'list-table':
172
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
173
						$found = true;
174
					}
175
					break;
176
				case 'edit':
177
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-payment-details' === $view ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
178
						$found = true;
179
					}
180
					break;
181
				default:
182
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
183
						$found = true;
184
					}
185
					break;
186
			}
187
			break;
188
		case 'reports':
189
			switch ( $passed_view ) {
190
				// If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ]
191
				case 'earnings':
192
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
193
						$found = true;
194
					}
195
					break;
196
				case 'donors':
197
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
198
						$found = true;
199
					}
200
					break;
201
				case 'gateways':
202 2
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
203
						$found = true;
204
					}
205
					break;
206
				case 'export':
207
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
208
						$found = true;
209
					}
210
					break;
211
				case 'logs':
212
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
213
						$found = true;
214
					}
215
					break;
216
				default:
217
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
218
						$found = true;
219
					}
220
					break;
221
			}
222
			break;
223
		case 'settings':
224
			switch ( $passed_view ) {
225
				case 'general':
226
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && ( 'general' === $tab || false === $tab ) ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
227
						$found = true;
228
					}
229
					break;
230
				case 'gateways':
231
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
232
						$found = true;
233
					}
234
					break;
235
				case 'emails':
236
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
237
						$found = true;
238
					}
239
					break;
240
				case 'display':
241
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
242
						$found = true;
243
					}
244
					break;
245
				case 'licenses':
246
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
247
						$found = true;
248
					}
249
					break;
250
				case 'api':
251 2
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
252
						$found = true;
253
					}
254
					break;
255
				case 'advanced':
256 2
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
257
						$found = true;
258
					}
259
					break;
260
				case 'system_info':
261
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
262
						$found = true;
263
					}
264
					break;
265
				default:
266
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
267
						$found = true;
268
					}
269
					break;
270
			}
271
			break;
272
		case 'addons':
273
			if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-addons' === $page ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
274
				$found = true;
275
			}
276
			break;
277
		case 'donors':
278
			switch ( $passed_view ) {
279
				case 'list-table':
280 2
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
281
						$found = true;
282
					}
283
					break;
284
				case 'overview':
285 2
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
286 2
						$found = true;
287
					}
288 2
					break;
289 2
				case 'notes':
290 2
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
291 2
						$found = true;
292 2
					}
293 2
					break;
294 2
				default:
295 2
					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
296
						$found = true;
297 2
					}
298 2
					break;
299
			}
300
			break;
301
		case 'reports':
302
			if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) {
0 ignored issues
show
introduced by
Found "== '". Use Yoda Condition checks, you must
Loading history...
303 2
				$found = true;
304 1
			}
305 1
			break;
306 2
		default:
307 2
			global $give_payments_page, $give_settings_page, $give_reports_page, $give_system_info_page, $give_add_ons_page, $give_settings_export, $give_donors_page, $give_tools_page;
308
309 2
			$admin_pages = apply_filters( 'give_admin_pages', array(
310
				$give_payments_page,
311 1
				$give_settings_page,
312
				$give_reports_page,
313
				$give_system_info_page,
314
				$give_add_ons_page,
315
				$give_settings_export,
316
				$give_donors_page,
317
				$give_tools_page,
318
				'widgets.php'
0 ignored issues
show
introduced by
Comma required after last value in array declaration
Loading history...
319
		) );
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 8.
Loading history...
320
			if ( 'give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow ) {
321
				$found = true;
322
			} elseif ( in_array( $pagenow, $admin_pages ) ) {
323
				$found = true;
324
			}
325
			break;
326
	}
327
328
	return (bool) apply_filters( 'give_is_admin_page', $found, $page, $view, $passed_page, $passed_view );
329
330
}
331
332
333
/**
334
 * Add setting tab to give-settings page
335
 *
336
 * @since  1.8
337
 * @param  array $settings
338
 * @return array
339
 */
340 View Code Duplication
function give_settings_page_pages( $settings ) {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
341
	include( 'abstract-admin-settings-page.php' );
342
	include( 'settings/class-settings-cmb2-backward-compatibility.php' );
343
344
	$settings = array(
345
		// General settings.
346
		include( 'settings/class-settings-general.php' ),
347
348
		// Payment Gateways Settings.
349
		include( 'settings/class-settings-gateways.php' ),
350
351
		// Display settings.
352
		include( 'settings/class-settings-display.php' ),
353
354
		// Emails settings.
355
		include( 'settings/class-settings-email.php' ),
356
357
		// Addons settings.
358
		include( 'settings/class-settings-addon.php' ),
359
360
		// License settings.
361
		include( 'settings/class-settings-license.php' ),
362
363
		// Advanced settings.
364
		include( 'settings/class-settings-advanced.php' )
0 ignored issues
show
introduced by
Comma required after last value in array declaration
Loading history...
365
	);
366
367
	// Output.
368
	return $settings;
369
}
370
add_filter( 'give-settings_get_settings_pages', 'give_settings_page_pages', 0, 1 );
371
372
373
/**
374
 * Add setting tab to give-settings page
375
 *
376
 * @since  1.8
377
 * @param  array $settings
378
 * @return array
379
 */
380
function give_reports_page_pages( $settings ) {
381
	include( 'abstract-admin-settings-page.php' );
382
383
	$settings = array(
384
		// Earnings.
385
		include( 'reports/class-earnings-report.php' ),
386
387
		// Forms.
388
		include( 'reports/class-forms-report.php' ),
389
390
		// Gateways.
391
		include( 'reports/class-gateways-report.php' ),
392
393
	);
394
395
	// Output.
396
	return $settings;
397
}
398
add_filter( 'give-reports_get_settings_pages', 'give_reports_page_pages', 0, 1 );
399
400
/**
401
 * Add setting tab to give-settings page
402
 *
403
 * @since  1.8
404
 * @param  array $settings
405
 * @return array
406
 */
407 View Code Duplication
function give_tools_page_pages( $settings ) {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
408
	include( 'abstract-admin-settings-page.php' );
409
410
	$settings = array(
411
		// System Info.
412
		include( 'tools/class-settings-system-info.php' ),
413
414
		// Logs.
415
		include( 'tools/class-settings-logs.php' ),
416
417
		// API.
418
		include( 'tools/class-settings-api.php' ),
419
420
		// Data.
421
		include( 'tools/class-settings-data.php' ),
422
423
		// Export.
424
		include( 'tools/class-settings-export.php' ),
425
426
		// Import.
427
		include( 'tools/class-settings-import.php' ),
428
429
	);
430
431
	// Output.
432
	return $settings;
433
}
434
add_filter( 'give-tools_get_settings_pages', 'give_tools_page_pages', 0, 1 );
435
436
/**
437
 * Set default tools page tab.
438
 *
439
 * @since  1.8
440
 * @param  string $default_tab Default tab name.
441
 * @return string
442
 */
443
function give_set_default_tab_form_tools_page( $default_tab ) {
0 ignored issues
show
Unused Code introduced by
The parameter $default_tab is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
444
	return 'system-info';
445
}
446
add_filter( 'give_default_setting_tab_give-tools', 'give_set_default_tab_form_tools_page', 10, 1 );
447
448
449
/**
450
 * Set default reports page tab.
451
 *
452
 * @since  1.8
453
 * @param  string $default_tab Default tab name.
454
 * @return string
455
 */
456
function give_set_default_tab_form_reports_page( $default_tab ) {
0 ignored issues
show
Unused Code introduced by
The parameter $default_tab is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
457
	return 'earnings';
458
}
459
add_filter( 'give_default_setting_tab_give-reports', 'give_set_default_tab_form_reports_page', 10, 1 );
460
461
462
/**
463
 * Add a page display state for special Give pages in the page list table.
464
 *
465
 * @since 1.8.18
466
 *
467
 * @param array $post_states An array of post display states.
468
 * @param WP_Post $post The current post object.
469
 *
470
 * @return array
471
 */
472
function give_add_display_page_states( $post_states, $post ) {
473
474
	switch( $post->ID ) {
0 ignored issues
show
introduced by
Space after opening control structure is required
Loading history...
introduced by
No space before opening parenthesis is prohibited
Loading history...
475
		case give_get_option( 'success_page' ):
476
			$post_states['give_successfully_page'] = __( 'Donation Success Page', 'give' );
477
			break;
478
479
		case give_get_option( 'failure_page' ):
480
			$post_states['give_failure_page'] = __( 'Donation Failed Page', 'give' );
481
			break;
482
483
		case give_get_option( 'history_page' ):
484
			$post_states['give_history_page'] = __( 'Donation History Page', 'give' );
485
			break;
486
	}
487
488
	return $post_states;
489
}
490
491
// Add a post display state for special Give pages.
492
add_filter( 'display_post_states', 'give_add_display_page_states', 10, 2 );