1
|
|
|
<?php |
|
|
|
|
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' ); |
|
|
|
|
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' ); |
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.