PluginProbe
Code Snippets / 3.1.0
Code Snippets v3.1.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.1.0, at php/settings/settings-fields.php

213 lines 5.9 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 fields 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
15 */
16 function get_default_settings() {
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 $defaults[ $section_id ][ $field_id ] = $field_atts['default'];
30 }
31 }
32
33 return $defaults;
34 }
35
36 /**
37 * Retrieve the settings fields
38 *
39 * @return array
40 */
41 function get_settings_fields() {
42 static $fields;
43
44 if ( isset( $fields ) ) {
45 return $fields;
46 }
47
48 $fields = [];
49
50 $fields['general'] = [
51 'activate_by_default' => [
52 'name' => __( 'Activate by Default', 'code-snippets' ),
53 'type' => 'checkbox',
54 'label' => __( "Make the 'Save and Activate' button the default action when saving a snippet.", 'code-snippets' ),
55 'default' => true,
56 ],
57
58 'enable_tags' => [
59 'name' => __( 'Enable Snippet Tags', 'code-snippets' ),
60 'type' => 'checkbox',
61 'label' => __( 'Show snippet tags on admin pages.', 'code-snippets' ),
62 'default' => true,
63 ],
64
65 'enable_description' => [
66 'name' => __( 'Enable Snippet Descriptions', 'code-snippets' ),
67 'type' => 'checkbox',
68 'label' => __( 'Show snippet descriptions on admin pages.', 'code-snippets' ),
69 'default' => true,
70 ],
71
72 'list_order' => [
73 'name' => __( 'Snippets List Order', 'code-snippets' ),
74 'type' => 'select',
75 'desc' => __( 'Default way to order snippets on the All Snippets admin menu.', 'code-snippets' ),
76 'options' => [
77 'priority-asc' => __( 'Priority', 'code-snippets' ),
78 'name-asc' => __( 'Name (A-Z)', 'code-snippets' ),
79 'name-desc' => __( 'Name (Z-A)', 'code-snippets' ),
80 'modified-desc' => __( 'Modified (latest first)', 'code-snippets' ),
81 'modified-asc' => __( 'Modified (oldest first)', 'code-snippets' ),
82 ],
83 'default' => 'priority',
84 ],
85
86 'disable_prism' => [
87 'name' => __( 'Disable Shortcode Syntax Highlighter', 'code-snippets' ),
88 'type' => 'checkbox',
89 'label' => __( 'Disable the syntax highlighting for the [code_snippet] shortcode on the front-end.', 'code-snippets' ),
90 'default' => false,
91 ],
92
93 'complete_uninstall' => [
94 'name' => __( 'Complete Uninstall', 'code-snippets' ),
95 'type' => 'checkbox',
96 'label' => __( 'When the plugin is deleted from the Plugins menu, also delete all snippets and plugin settings.', 'code-snippets' ),
97 'default' => false,
98 ],
99 ];
100
101 if ( is_multisite() && ! is_main_site() ) {
102 unset( $fields['general']['complete_uninstall'] );
103 }
104
105 /* Description Editor settings section */
106 $fields['description_editor'] = [
107
108 'rows' => [
109 'name' => __( 'Row Height', 'code-snippets' ),
110 'type' => 'number',
111 'label' => __( 'rows', 'code-snippets' ),
112 'default' => 5,
113 'min' => 0,
114 ],
115
116 'use_full_mce' => [
117 'name' => __( 'Use Full Editor', 'code-snippets' ),
118 'type' => 'checkbox',
119 'label' => __( 'Enable all features of the visual editor.', 'code-snippets' ),
120 'default' => false,
121 ],
122
123 'media_buttons' => [
124 'name' => __( 'Media Buttons', 'code-snippets' ),
125 'type' => 'checkbox',
126 'label' => __( 'Enable the add media buttons.', 'code-snippets' ),
127 'default' => false,
128 ],
129 ];
130
131 /* Code Editor settings section */
132
133 $fields['editor'] = [
134 'theme' => [
135 'name' => __( 'Theme', 'code-snippets' ),
136 'type' => 'select',
137 'default' => 'default',
138 'options' => get_editor_theme_list(),
139 'codemirror' => 'theme',
140 ],
141
142 'indent_with_tabs' => [
143 'name' => __( 'Indent With Tabs', 'code-snippets' ),
144 'type' => 'checkbox',
145 'label' => __( 'Use hard tabs (not spaces) for indentation.', 'code-snippets' ),
146 'default' => true,
147 'codemirror' => 'indentWithTabs',
148 ],
149
150 'tab_size' => [
151 'name' => __( 'Tab Size', 'code-snippets' ),
152 'type' => 'number',
153 'desc' => __( 'The width of a tab character.', 'code-snippets' ),
154 'default' => 4,
155 'codemirror' => 'tabSize',
156 'min' => 0,
157 ],
158
159 'indent_unit' => [
160 'name' => __( 'Indent Unit', 'code-snippets' ),
161 'type' => 'number',
162 'desc' => __( 'How many spaces a block should be indented.', 'code-snippets' ),
163 'default' => 4,
164 'codemirror' => 'indentUnit',
165 'min' => 0,
166 ],
167
168 'wrap_lines' => [
169 'name' => __( 'Wrap Lines', 'code-snippets' ),
170 'type' => 'checkbox',
171 'label' => __( 'Whether the editor should scroll or wrap for long lines.', 'code-snippets' ),
172 'default' => true,
173 'codemirror' => 'lineWrapping',
174 ],
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 'default' => true,
181 'codemirror' => 'lineNumbers',
182 ],
183
184 'auto_close_brackets' => [
185 'name' => __( 'Auto Close Brackets', 'code-snippets' ),
186 'type' => 'checkbox',
187 'label' => __( 'Auto-close brackets and quotes when typed.', 'code-snippets' ),
188 'default' => true,
189 'codemirror' => 'autoCloseBrackets',
190 ],
191
192 'highlight_selection_matches' => [
193 'name' => __( 'Highlight Selection Matches', 'code-snippets' ),
194 'label' => __( 'Highlight all instances of a currently selected word.', 'code-snippets' ),
195 'type' => 'checkbox',
196 'default' => true,
197 'codemirror' => 'highlightSelectionMatches',
198 ],
199
200 'highlight_active_line' => [
201 'name' => __( 'Highlight Active Line', 'code-snippets' ),
202 'label' => __( 'Highlight the line that is currently being edited.', 'code-snippets' ),
203 'type' => 'checkbox',
204 'default' => true,
205 'codemirror' => 'styleActiveLine',
206 ],
207 ];
208
209 $fields = apply_filters( 'code_snippets_settings_fields', $fields );
210
211 return $fields;
212 }
213