settings.php ➔ printcenter_settings_tabs()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 22 and the first side effect is on line 11.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Settings
4
 *
5
 * @package     PrintCenter\Admin\Settings
6
 * @since       1.0.0
7
 */
8
9
// Exit if accessed directly
10
if( ! defined( 'ABSPATH' ) ) {
11
	exit;
12
}
13
14
15
/**
16
 * Add the settings menu item
17
 *
18
 * @since       1.0.0
19
 * @param       array $menu The existing menu settings
20
 * @return      array $menu The updated menu settings
21
 */
22
function printcenter_menu( $menu ) {
23
	$menu['page_title'] = __( 'PrintCenter Settings', 'printcenter' );
24
	$menu['menu_title'] = __( 'PrintCenter', 'printcenter' );
25
26
	return $menu;
27
}
28
add_filter( 'printcenter_menu', 'printcenter_menu' );
29
30
31
/**
32
 * Add the settings menu item
33
 *
34
 * @since       1.0.0
35
 * @param       array $tabs The existing settings tabs
36
 * @return      array $tabs The updated settings tabs
37
 */
38
function printcenter_settings_tabs( $tabs ) {
39
	$tabs['ssi']   = __( 'SSI', 'printcenter' );
40
	//$tabs['email'] = __( 'Email', 'printcenter' );
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
42
	return $tabs;
43
}
44
add_filter( 'printcenter_settings_tabs', 'printcenter_settings_tabs' );
45
46
47
/**
48
 * Add the settings
49
 *
50
 * @since       1.0.0
51
 * @param       array $settings The existing settings
52
 * @return      array $settings The updated settings
53
 */
54
function printcenter_settings( $settings ) {
55
	$plugin_settings = array(
56
		'ssi' => apply_filters( 'printcenter_ssi_settings', array(
57
			array(
58
				'id'   => 'ssi_header',
59
				'name' => __( 'SSI Settings', 'printcenter' ),
60
				'desc' => '',
61
				'type' => 'header'
62
			),
63
			array(
64
				'id'      => 'ssi_mode',
65
				'name'    => __( 'Processing Mode', 'printcenter' ),
66
				'desc'    => __( 'Choose the SSI data processing mode', 'printcenter' ),
67
				'type'    => 'select',
68
				'options' => array(
69
					'live'    => __( 'Live', 'printcenter' ),
70
					'test'    => __( 'Test', 'printcenter' ),
71
					'capture' => __( 'Capture', 'printcenter' )
72
				)
73
			),
74
			array(
75
				'id'   => 'ssi_custid',
76
				'name' => __( 'Live Customer ID', 'printcenter' ),
77
				'desc' => __( 'Your SSI customer ID', 'printcenter' ),
78
				'type' => 'text',
79
				'std'  => '1024'
80
			),
81
			array(
82
				'id'   => 'ssi_custzip',
83
				'name' => __( 'Live Customer Zip Code', 'printcenter' ),
84
				'desc' => __( 'Your SSI billing zip code', 'printcenter' ),
85
				'type' => 'text',
86
				'std'  => '80304'
87
			),
88
			array(
89
				'id'   => 'ssi_test_custid',
90
				'name' => __( 'Test Customer ID', 'printcenter' ),
91
				'desc' => __( 'Test ID provided by SSI', 'printcenter' ),
92
				'type' => 'text',
93
				'std'  => '1013'
94
			),
95
			array(
96
				'id'   => 'ssi_test_custzip',
97
				'name' => __( 'Test Zip Code', 'printcenter' ),
98
				'desc' => __( 'Test zip code provided by SSI', 'printcenter' ),
99
				'type' => 'text',
100
				'std'  => '99999'
101
			)
102
		) )
103
	);
104
105
	return array_merge( $settings, $plugin_settings );
106
}
107
add_filter( 'printcenter_registered_settings', 'printcenter_settings' );