This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * Settings |
||
4 | * |
||
5 | * @package S214_Settings_Demo\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 plugin menu item |
||
17 | * |
||
18 | * @since 1.0.0 |
||
19 | * @param array $menu The default menu settings |
||
20 | * @return array $menu Our customized settings |
||
21 | */ |
||
22 | function s214_settings_demo_add_menu( $menu ) { |
||
23 | $menu['page_title'] = __( 'S214 Settings Demo', 's214-settings-demo' ); // Can be set to 'submenu' or 'menu'. Defaults to 'menu'. |
||
24 | //$menu['parent'] = 'options-general.php'; // If 'type' is set to 'submenu', defines the parent menu to place our menu under. Defaults to 'options-general.php' |
||
25 | $menu['page_title'] = __( 'S214 Settings Demo', 's214-settings-demo' ); // The page title. Defaults to 'Section214 Settings'. |
||
26 | $menu['show_title'] = true; // Whether or not to display the title at the top of the page. |
||
27 | $menu['menu_title'] = __( 'S214 Settings', 's214-settings-demo' ); // The menu title. Defaults to 'Section214 Settings'. |
||
28 | //$menu['capability'] = 'manage_options'; // The minimum capability required to access the settings panel. Defaults to 'manage_options'. |
||
29 | $menu['icon'] = 'dashicons-warning'; // An (optional) icon for your menu item. Follows the same standards as the add_menu_item() function in WordPress. |
||
30 | //$menu['position'] = null; // Where in the menu to display our new menu. Defaults to 'null' (bottom of the menu). |
||
31 | |||
32 | return $menu; |
||
33 | } |
||
34 | add_filter( 's214_settings_demo_menu', 's214_settings_demo_add_menu' ); |
||
35 | |||
36 | |||
37 | /** |
||
38 | * Define the tabs for the settings panel |
||
39 | * |
||
40 | * @since 1.0.0 |
||
41 | * @param array $tabs The default settings tabs |
||
42 | * @return array $tabs Our customized tabs |
||
43 | */ |
||
44 | function s214_settings_demo_settings_tabs( $tabs ) { |
||
45 | $tabs = array( |
||
46 | 'welcome' => __( 'Welcome', 's214-settings-demo' ), |
||
47 | 'fields' => __( 'Fields', 's214-settings-demo' ) |
||
48 | ); |
||
49 | |||
50 | return $tabs; |
||
51 | } |
||
52 | add_filter( 's214_settings_demo_settings_tabs', 's214_settings_demo_settings_tabs' ); |
||
53 | |||
54 | |||
55 | /** |
||
56 | * Define the unsavable tabs for the settings panel |
||
57 | * |
||
58 | * @since 1.0.0 |
||
59 | * @param array $tabs The default unsavable tabs |
||
60 | * @return array $tabs Our customized tabs |
||
61 | */ |
||
62 | function s214_settings_demo_unsavable_tabs( $tabs ) { |
||
63 | $tabs = array( |
||
64 | 'welcome' |
||
65 | ); |
||
66 | |||
67 | return $tabs; |
||
68 | } |
||
69 | add_filter( 's214_settings_demo_unsavable_tabs', 's214_settings_demo_unsavable_tabs' ); |
||
70 | |||
71 | |||
72 | /** |
||
73 | * Define the settings sections for the each tab |
||
74 | * |
||
75 | * @since 1.0.0 |
||
76 | * @param array $tabs The default settings sections |
||
77 | * @return array $tabs Our customized sections |
||
78 | */ |
||
79 | function s214_settings_demo_settings_sections( $sections ) { |
||
80 | $sections = array( |
||
81 | 'welcome' => array( |
||
82 | 'main' => __( 'Welcome Aboard!', 's214-settings-demo' ) |
||
83 | ), |
||
84 | 'fields' => array( |
||
85 | 'text' => __( 'Text Fields', 's214-settings-demo' ), |
||
86 | 'option' => __( 'Option Fields', 's214-settings-demo' ), |
||
87 | 'misc' => __( 'Misc Fields', 's214-settings-demo' ), |
||
88 | 'advanced' => __( 'Advanced Fields', 's214-settings-demo' ) |
||
89 | ) |
||
90 | ); |
||
91 | |||
92 | return $sections; |
||
93 | } |
||
94 | add_filter( 's214_settings_demo_registered_settings_sections', 's214_settings_demo_settings_sections' ); |
||
95 | |||
96 | |||
97 | /** |
||
98 | * Define the settings for the settings panel |
||
99 | * |
||
100 | * @since 1.0.0 |
||
101 | * @param array $settings The default settings |
||
102 | * @return array $settings Our customized settings |
||
103 | */ |
||
104 | function s214_settings_demo_settings( $settings ) { |
||
105 | $plugin_settings = array( |
||
106 | 'welcome' => array( |
||
107 | 'main' => array( |
||
108 | array( |
||
109 | 'id' => 'welcome_header', |
||
110 | 'name' => __( 'Welcome Aboard!', 's214-settings-demo' ), |
||
111 | 'desc' => '', |
||
112 | 'type' => 'header' |
||
113 | ), |
||
114 | array( |
||
115 | 'id' => 'welcome_note', |
||
116 | 'name' => '', |
||
117 | 'desc' => sprintf( __( 'This plugin will attempt to familiarize you with the various things this library is capable of. Just in case it wasn\'t obvious, the "Welcome Aboard" text above is an example of a %s field, and this field is a %s field. Remember, every field takes \'id\', \'name\', \'desc\' and \'type\' arguments!', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#header-implements-a-simple-header" target="_blank"><code>header</code></a>', '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#descriptive_text-implements-a-descriptive-text-field" target="_blank"><code>descriptive_text</code></a>' ), |
||
118 | 'type' => 'descriptive_text', |
||
119 | 'tooltip_title' => __( 'Hi There!', 's214-settings-demo' ), |
||
120 | 'tooltip_desc' => __( 'Other than the \'header\' and \'hook\' field types, all fields can display a tooltip. Do this by adding \'tooltip_title\' and \'tooltip_desc\' arguments to the field array.', 's214-settings-demo' ) |
||
121 | ), |
||
122 | array( |
||
123 | 'id' => 'thanks', |
||
124 | 'name' => __( 'Thanks EDD!', 's214-settings-demo' ), |
||
125 | 'desc' => '', |
||
126 | 'type' => 'hook' |
||
127 | ) |
||
128 | ) |
||
129 | ), |
||
130 | 'fields' => array( |
||
131 | 'text' => array( |
||
132 | array( |
||
133 | 'id' => 'text_header', |
||
134 | 'name' => __( 'Text Field Examples', 's214-settings-demo' ), |
||
135 | 'desc' => '', |
||
136 | 'type' => 'header' |
||
137 | ), |
||
138 | array( |
||
139 | 'id' => 'text', |
||
140 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'text' ), |
||
141 | 'desc' => sprintf( __( 'Text fields can take \'std\', \'readonly\' and \'size\' arguements. Read more about text fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#text-implements-a-text-field" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
142 | 'type' => 'text', |
||
143 | 'std' => 'This is a text field' |
||
144 | ), |
||
145 | array( |
||
146 | 'id' => 'textarea', |
||
147 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'textarea' ), |
||
148 | 'desc' => sprintf( __( 'Textarea fields can take a \'std\' arguement. Read more about textarea fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#textarea-implements-a-text-area" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
149 | 'type' => 'textarea' |
||
150 | ), |
||
151 | array( |
||
152 | 'id' => 'editor', |
||
153 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'editor' ), |
||
154 | 'desc' => sprintf( __( 'Editor fields can take \'std\', \'allow_blank\', \'size\', \'wpautop\', \'buttons\' and \'teeny\' arguements. Read more about editor fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#editor-implements-a-rich-text-editor" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
155 | 'type' => 'editor' |
||
156 | ), |
||
157 | array( |
||
158 | 'id' => 'html', |
||
159 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'html' ), |
||
160 | 'desc' => sprintf( __( 'HTML fields can take a \'std\' arguement. Read more about HTML fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#html-implements-a-codemirror-html-field" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
161 | 'type' => 'html' |
||
162 | ), |
||
163 | array( |
||
164 | 'id' => 'password', |
||
165 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'password' ), |
||
166 | 'desc' => sprintf( __( 'Password fields can take \'std\' and \'size\' arguements. Read more about password fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#password-implements-a-password-field" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
167 | 'type' => 'password' |
||
168 | ) |
||
169 | ), |
||
170 | 'option' => array( |
||
171 | array( |
||
172 | 'id' => 'option_header', |
||
173 | 'name' => __( 'Option Field Examples', 's214-settings-demo' ), |
||
174 | 'desc' => '', |
||
175 | 'type' => 'header' |
||
176 | ), |
||
177 | array( |
||
178 | 'id' => 'checkbox', |
||
179 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'checkbox' ), |
||
180 | 'desc' => sprintf( __( 'Checkbox fields only take the basic arguements. Read more about checkbox fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#checkbox-implements-a-checkbox" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
181 | 'type' => 'checkbox' |
||
182 | ), |
||
183 | array( |
||
184 | 'id' => 'multicheck', |
||
185 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'multicheck' ), |
||
186 | 'desc' => sprintf( __( 'Multicheck fields only take the basic arguements. Read more about multicheck fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#multicheck-implements-a-multicheck-field" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
187 | 'type' => 'multicheck', |
||
188 | 'options' => array( |
||
189 | 'option1' => __( 'Option 1', 's214-settings-demo' ), |
||
190 | 'option2' => __( 'Option 2', 's214-settings-demo' ), |
||
191 | 'option3' => __( 'Option 3', 's214-settings-demo' ) |
||
192 | ) |
||
193 | ), |
||
194 | array( |
||
195 | 'id' => 'radio', |
||
196 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'radio' ), |
||
197 | 'desc' => sprintf( __( 'Radio fields can take a \'std\' arguement. Read more about radio fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#radio-implements-a-radio-button-list-field" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
198 | 'type' => 'radio', |
||
199 | 'options' => array( |
||
200 | 'option1' => __( 'Option 1', 's214-settings-demo' ), |
||
201 | 'option2' => __( 'Option 2', 's214-settings-demo' ), |
||
202 | 'option3' => __( 'Option 3', 's214-settings-demo' ) |
||
203 | ) |
||
204 | ), |
||
205 | array( |
||
206 | 'id' => 'select', |
||
207 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'select' ), |
||
208 | 'desc' => sprintf( __( 'Select fields can take \'std\', \'placeholder\', \'select2\' and \'multiple\' arguements. Read more about select fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#select-implements-a-select-field" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
209 | 'type' => 'select', |
||
210 | 'options' => array( |
||
211 | 'option1' => __( 'Option 1', 's214-settings-demo' ), |
||
212 | 'option2' => __( 'Option 2', 's214-settings-demo' ), |
||
213 | 'option3' => __( 'Option 3', 's214-settings-demo' ) |
||
214 | ) |
||
215 | ) |
||
216 | ), |
||
217 | 'misc' => array( |
||
218 | array( |
||
219 | 'id' => 'misc_header', |
||
220 | 'name' => __( 'Misc Field Examples', 's214-settings-demo' ), |
||
221 | 'desc' => '', |
||
222 | 'type' => 'header' |
||
223 | ), |
||
224 | array( |
||
225 | 'id' => 'color', |
||
226 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'color' ), |
||
227 | 'desc' => sprintf( __( 'Color fields can take a \'std\' arguement. Read more about color fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#color-implements-a-color-select-field" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
228 | 'type' => 'color', |
||
229 | 'std' => '#000000' |
||
230 | ), |
||
231 | array( |
||
232 | 'id' => 'number', |
||
233 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'number' ), |
||
234 | 'desc' => sprintf( __( 'Number fields can take \'std\', \'max\', \'min\', \'step\', \'size\' and \'readonly\' arguements. Read more about number fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#number-implements-a-number-field" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
235 | 'type' => 'number', |
||
236 | 'std' => 1227 |
||
237 | ), |
||
238 | array( |
||
239 | 'id' => 'upload', |
||
240 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'upload' ), |
||
241 | 'desc' => sprintf( __( 'Upload fields can take \'std\' and \'size\' arguements. Read more about upload fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#upload-implements-an-upload-field" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
242 | 'type' => 'upload' |
||
243 | ) |
||
244 | ), |
||
245 | 'advanced' => array( |
||
246 | array( |
||
247 | 'id' => 'advanced_header', |
||
248 | 'name' => __( 'Advanced Field Examples', 's214-settings-demo' ), |
||
249 | 'desc' => '', |
||
250 | 'type' => 'header' |
||
251 | ), |
||
252 | array( |
||
253 | 'id' => 'sysinfo', |
||
254 | 'name' => sprintf( __( '%s Field', 's214-settings-demo' ), 'sysinfo' ), |
||
255 | 'desc' => sprintf( __( 'Sysinfo fields only take the basic arguements. Read more about sysinfo fields %s.', 's214-settings-demo' ), '<a href="https://github.com/Section214/S214-Settings/wiki/Settings-Reference#sysinfo-implements-a-system-info-display-field" target="_blank">' . __( 'here', 's214-settings-demo' ) . '</a>' ), |
||
256 | 'type' => 'sysinfo', |
||
257 | 'tab' => 'advanced' |
||
258 | ) |
||
259 | ) |
||
260 | ) |
||
261 | ); |
||
262 | |||
263 | return array_merge( $settings, $plugin_settings ); |
||
264 | } |
||
265 | add_filter( 's214_settings_demo_registered_settings', 's214_settings_demo_settings' ); |
||
266 |
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.