PluginProbe
Code Snippets / 3.6.6
Code Snippets v3.6.6
3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 3.0.1 All 64 releases
code-snippets / php / settings / settings-fields.php

settings-fields.php in Code Snippets 3.6.6, at php/settings/settings-fields.php

239 lines 7.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Manages the settings field definitions.
4 *
5 * @package Code_Snippets
6 * @subpackage Settings
7 */
8
9 namespace Code_Snippets\Settings;
10
11 /**
12 * Retrieve the default setting values
13 *
14 * @return array<string, array<string, array>>
15 */
16 function get_default_settings(): array {
17 static $defaults;
18
19 if ( isset( $defaults ) ) {
20 return $defaults;
21 }
22
23 $defaults = array();
24
25 foreach ( get_settings_fields() as $section_id => $fields ) {
26 $defaults[ $section_id ] = array();
27
28 foreach ( $fields as $field_id => $field_atts ) {
29 if ( isset( $field_atts['default'] ) ) {
30 $defaults[ $section_id ][ $field_id ] = $field_atts['default'];
31 }
32 }
33 }
34
35 return $defaults;
36 }
37
38 /**
39 * Retrieve the settings fields
40 *
41 * @return array<string, array<string, array>>
42 */
43 function get_settings_fields(): array {
44 static $fields;
45
46 if ( isset( $fields ) ) {
47 return $fields;
48 }
49
50 $fields = [];
51
52 $fields['debug'] = [
53 'database_update' => [
54 'name' => __( 'Database Table Upgrade', 'code-snippets' ),
55 'type' => 'action',
56 'label' => __( 'Upgrade Database Table', 'code-snippets' ),
57 'desc' => __( 'Use this button to manually upgrade the Code Snippets database table. This action will only affect the snippets table and should be used only when necessary.', 'code-snippets' ),
58 ],
59 'reset_caches' => [
60 'name' => __( 'Reset Caches', 'code-snippets' ),
61 'type' => 'action',
62 'desc' => __( 'Use this button to manually clear snippets caches.', 'code-snippets' ),
63 ],
64 ];
65
66 $fields['general'] = [
67 'activate_by_default' => [
68 'name' => __( 'Activate by Default', 'code-snippets' ),
69 'type' => 'checkbox',
70 'label' => __( "Make the 'Save and Activate' button the default action when saving a snippet.", 'code-snippets' ),
71 'default' => true,
72 ],
73
74 'enable_tags' => [
75 'name' => __( 'Enable Snippet Tags', 'code-snippets' ),
76 'type' => 'checkbox',
77 'label' => __( 'Show snippet tags on admin pages.', 'code-snippets' ),
78 'default' => true,
79 ],
80
81 'enable_description' => [
82 'name' => __( 'Enable Snippet Descriptions', 'code-snippets' ),
83 'type' => 'checkbox',
84 'label' => __( 'Show snippet descriptions on admin pages.', 'code-snippets' ),
85 'default' => true,
86 ],
87
88 'visual_editor_rows' => [
89 'name' => __( 'Description Editor Height', 'code-snippets' ),
90 'type' => 'number',
91 'label' => _x( 'rows', 'unit', 'code-snippets' ),
92 'default' => 5,
93 'min' => 0,
94 ],
95
96 'list_order' => [
97 'name' => __( 'Snippets List Order', 'code-snippets' ),
98 'type' => 'select',
99 'desc' => __( 'Default way to order snippets on the All Snippets admin menu.', 'code-snippets' ),
100 'options' => [
101 'priority-asc' => __( 'Priority', 'code-snippets' ),
102 'name-asc' => __( 'Name (A-Z)', 'code-snippets' ),
103 'name-desc' => __( 'Name (Z-A)', 'code-snippets' ),
104 'modified-desc' => __( 'Modified (latest first)', 'code-snippets' ),
105 'modified-asc' => __( 'Modified (oldest first)', 'code-snippets' ),
106 ],
107 'default' => 'priority-asc',
108 ],
109
110 'disable_prism' => [
111 'name' => __( 'Disable Syntax Highlighter', 'code-snippets' ),
112 'type' => 'checkbox',
113 'label' => __( 'Disable syntax highlighting when displaying snippet code on the front-end.', 'code-snippets' ),
114 'default' => false,
115 ],
116
117 'hide_upgrade_menu' => [
118 'name' => __( 'Hide Upgrade Menu', 'code-snippets' ),
119 'type' => 'checkbox',
120 'label' => __( 'Hide the Upgrade button from the admin menu.', 'code-snippets' ),
121 'default' => false,
122 ],
123 ];
124
125 if ( ! is_multisite() || is_main_site() ) {
126 $fields['general']['complete_uninstall'] = [
127 'name' => __( 'Complete Uninstall', 'code-snippets' ),
128 'type' => 'checkbox',
129 'label' => __( 'When the plugin is deleted from the Plugins menu, also delete all snippets and plugin settings.', 'code-snippets' ),
130 'default' => false,
131 ];
132 }
133
134 // Code Editor settings section.
135
136 $fields['editor'] = [
137 'theme' => [
138 'name' => __( 'Theme', 'code-snippets' ),
139 'type' => 'select',
140 'default' => 'default',
141 'options' => get_editor_theme_list(),
142 'codemirror' => 'theme',
143 ],
144
145 'indent_with_tabs' => [
146 'name' => __( 'Indent With Tabs', 'code-snippets' ),
147 'type' => 'checkbox',
148 'label' => __( 'Use hard tabs instead of spaces for indentation.', 'code-snippets' ),
149 'default' => true,
150 'codemirror' => 'indentWithTabs',
151 ],
152
153 'tab_size' => [
154 'name' => __( 'Tab Size', 'code-snippets' ),
155 'type' => 'number',
156 'desc' => __( 'The width of a tab character.', 'code-snippets' ),
157 'default' => 4,
158 'label' => _x( 'spaces', 'unit', 'code-snippets' ),
159 'codemirror' => 'tabSize',
160 'min' => 0,
161 ],
162
163 'indent_unit' => [
164 'name' => __( 'Indent Unit', 'code-snippets' ),
165 'type' => 'number',
166 'desc' => __( 'The number of spaces to indent a block.', 'code-snippets' ),
167 'default' => 4,
168 'label' => _x( 'spaces', 'unit', 'code-snippets' ),
169 'codemirror' => 'indentUnit',
170 'min' => 0,
171 ],
172
173 'wrap_lines' => [
174 'name' => __( 'Wrap Lines', 'code-snippets' ),
175 'type' => 'checkbox',
176 'label' => __( 'Soft-wrap long lines of code instead of horizontally scrolling.', 'code-snippets' ),
177 'default' => true,
178 'codemirror' => 'lineWrapping',
179 ],
180
181 'code_folding' => [
182 'name' => __( 'Code Folding', 'code-snippets' ),
183 'type' => 'checkbox',
184 'label' => __( 'Allow folding functions or other blocks into a single line.', 'code-snippets' ),
185 'default' => true,
186 'codemirror' => 'foldGutter',
187 ],
188
189 'line_numbers' => [
190 'name' => __( 'Line Numbers', 'code-snippets' ),
191 'type' => 'checkbox',
192 'label' => __( 'Show line numbers to the left of the editor.', 'code-snippets' ),
193 'default' => true,
194 'codemirror' => 'lineNumbers',
195 ],
196
197 'auto_close_brackets' => [
198 'name' => __( 'Auto Close Brackets', 'code-snippets' ),
199 'type' => 'checkbox',
200 'label' => __( 'Auto-close brackets and quotes when typed.', 'code-snippets' ),
201 'default' => true,
202 'codemirror' => 'autoCloseBrackets',
203 ],
204
205 'highlight_selection_matches' => [
206 'name' => __( 'Highlight Selection Matches', 'code-snippets' ),
207 'label' => __( 'Highlight all instances of a currently selected word.', 'code-snippets' ),
208 'type' => 'checkbox',
209 'default' => true,
210 'codemirror' => 'highlightSelectionMatches',
211 ],
212
213 'highlight_active_line' => [
214 'name' => __( 'Highlight Active Line', 'code-snippets' ),
215 'label' => __( 'Highlight the line that is currently being edited.', 'code-snippets' ),
216 'type' => 'checkbox',
217 'default' => true,
218 'codemirror' => 'styleActiveLine',
219 ],
220 'keymap' => [
221 'name' => __( 'Keymap', 'code-snippets' ),
222 'type' => 'select',
223 'desc' => __( 'The set of keyboard shortcuts to use in the code editor.', 'code-snippets' ),
224 'default' => 'default',
225 'options' => [
226 'default' => __( 'Default', 'code-snippets' ),
227 'vim' => __( 'Vim', 'code-snippets' ),
228 'emacs' => __( 'Emacs', 'code-snippets' ),
229 'sublime' => __( 'Sublime Text', 'code-snippets' ),
230 ],
231 'codemirror' => 'keyMap',
232 ],
233 ];
234
235 $fields = apply_filters( 'code_snippets_settings_fields', $fields );
236
237 return $fields;
238 }
239