File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ private static function set_fields() {
68
68
'type ' => 'number ' ,
69
69
'label ' => 'rows ' ,
70
70
'default ' => 5 ,
71
+ 'min ' => 0 ,
71
72
),
72
73
73
74
array (
@@ -114,6 +115,7 @@ private static function set_fields() {
114
115
'desc ' => __ ( 'The width of a tab character. ' , 'code-snippets ' ),
115
116
'default ' => 4 ,
116
117
'codemirror ' => 'tabSize ' ,
118
+ 'min ' => 0 ,
117
119
),
118
120
119
121
array (
@@ -123,6 +125,7 @@ private static function set_fields() {
123
125
'desc ' => __ ( 'How many spaces a block should be indented. ' , 'code-snippets ' ),
124
126
'default ' => 2 ,
125
127
'codemirror ' => 'indentUnit ' ,
128
+ 'min ' => 0 ,
126
129
),
127
130
128
131
array (
Original file line number Diff line number Diff line change @@ -39,12 +39,22 @@ function code_snippets_checkbox_field( $atts ) {
39
39
function code_snippets_number_field ( $ atts ) {
40
40
41
41
printf (
42
- '<input type="number" name="code_snippets_settings[%s][%s]" value="%s"> ' ,
42
+ '<input type="number" name="code_snippets_settings[%s][%s]" value="%s" ' ,
43
43
$ atts ['section ' ],
44
44
$ atts ['id ' ],
45
45
code_snippets_get_setting ( $ atts ['section ' ], $ atts ['id ' ] )
46
46
);
47
47
48
+ if ( isset ( $ atts ['min ' ] ) ) {
49
+ printf ( ' min="%d" ' , $ atts ['min ' ] );
50
+ }
51
+
52
+ if ( isset ( $ atts ['max ' ] ) ) {
53
+ printf ( ' max="%d" ' , $ atts ['max ' ] );
54
+ }
55
+
56
+ echo '> ' ;
57
+
48
58
if ( ! empty ( $ atts ['label ' ] ) ) {
49
59
echo ' ' . $ atts ['label ' ];
50
60
}
Original file line number Diff line number Diff line change @@ -121,16 +121,18 @@ function code_snippets_register_settings() {
121
121
}
122
122
123
123
/* Register settings fields */
124
- foreach ( code_snippets_get_settings_fields () as $ section_id => $ fields ) {
125
-
124
+ foreach ( Code_Snippets_Settings::get_fields () as $ section_id => $ fields ) {
126
125
foreach ( $ fields as $ field ) {
126
+ $ atts = $ field ;
127
+ $ atts ['section ' ] = $ section_id ;
128
+
127
129
add_settings_field (
128
130
'code_snippets_ ' . $ field ['id ' ],
129
131
$ field ['name ' ],
130
132
"code_snippets_ {$ field ['type ' ]}_field " ,
131
133
'code-snippets ' ,
132
134
'code-snippets- ' . $ section_id ,
133
- array_merge ( $ field , array ( ' section ' => $ section_id ) )
135
+ $ atts
134
136
);
135
137
}
136
138
}
You can’t perform that action at this time.
0 commit comments