PluginProbe
Code Snippets / 3.7.0
Code Snippets v3.7.0
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.7.0, at php/settings/settings-fields.php

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