@@ -45,6 +45,15 @@ public function sunflower_add_plugin_page(): void {
45
45
public function create_sunflower_settings_page (): void {
46
46
// Set class properties from options.
47
47
$ this ->options = get_option ( 'sunflower_options ' );
48
+
49
+ if ( ! is_array ( $ this ->options ) ) {
50
+ $ this ->options = array ();
51
+ }
52
+
53
+ // Set default values.
54
+ $ this ->options ['sunflower_schema_org ' ] = $ this ->options ['sunflower_schema_org ' ] ?? 'checked ' ;
55
+ $ this ->options ['sunflower_categories_archive ' ] = $ this ->options ['sunflower_categories_archive ' ] ?? 'main-categories ' ;
56
+
48
57
?>
49
58
<div class="wrap">
50
59
<h1><?php esc_html_e ( 'Sunflower Settings ' , 'sunflower ' ); ?> </h1>
@@ -115,7 +124,10 @@ public function sunflower_settings_page_init(): void {
115
124
$ this ->sunflower_checkbox_callback ( ... ),
116
125
'sunflower-setting-admin ' ,
117
126
'sunflower_layout ' ,
118
- array ( 'sunflower_show_related_posts ' , __ ( 'show related posts ' , 'sunflower ' ) )
127
+ array (
128
+ 'field ' => 'sunflower_show_related_posts ' ,
129
+ 'label ' => __ ( 'show related posts ' , 'sunflower ' ),
130
+ )
119
131
);
120
132
121
133
add_settings_field (
@@ -124,7 +136,10 @@ public function sunflower_settings_page_init(): void {
124
136
$ this ->sunflower_checkbox_callback ( ... ),
125
137
'sunflower-setting-admin ' ,
126
138
'sunflower_layout ' ,
127
- array ( 'sunflower_show_author ' , __ ( 'Show post author on post details and via REST api. ' , 'sunflower ' ) )
139
+ array (
140
+ 'field ' => 'sunflower_show_author ' ,
141
+ 'label ' => __ ( 'Show post author on post details and via REST api. ' , 'sunflower ' ),
142
+ )
128
143
);
129
144
130
145
add_settings_field (
@@ -133,7 +148,10 @@ public function sunflower_settings_page_init(): void {
133
148
$ this ->sunflower_checkbox_callback ( ... ),
134
149
'sunflower-setting-admin ' ,
135
150
'sunflower_layout ' ,
136
- array ( 'sunflower_hide_prev_next ' , __ ( 'hide previous and next links ' , 'sunflower ' ) )
151
+ array (
152
+ 'field ' => 'sunflower_hide_prev_next ' ,
153
+ 'label ' => __ ( 'hide previous and next links ' , 'sunflower ' ),
154
+ )
137
155
);
138
156
139
157
add_settings_field (
@@ -151,7 +169,10 @@ public function sunflower_settings_page_init(): void {
151
169
$ this ->sunflower_checkbox_callback ( ... ),
152
170
'sunflower-setting-admin ' ,
153
171
'sunflower_layout ' ,
154
- array ( 'sunflower_main_menu_item_is_placeholder ' , __ ( 'items with href=# in the main menu are placeholders for submenu ' , 'sunflower ' ) )
172
+ array (
173
+ 'field ' => 'sunflower_main_menu_item_is_placeholder ' ,
174
+ 'label ' => __ ( 'items with href=# in the main menu are placeholders for submenu ' , 'sunflower ' ),
175
+ )
155
176
);
156
177
157
178
add_settings_field (
@@ -177,8 +198,19 @@ public function sunflower_settings_page_init(): void {
177
198
__ ( 'Show list of categories on category archive ' , 'sunflower ' ),
178
199
$ this ->sunflower_categories_archive ( ... ),
179
200
'sunflower-setting-admin ' ,
201
+ 'sunflower_layout '
202
+ );
203
+
204
+ add_settings_field (
205
+ 'sunflower_schema_org ' ,
206
+ __ ( 'Enhance SEO ' , 'sunflower ' ),
207
+ $ this ->sunflower_checkbox_callback ( ... ),
208
+ 'sunflower-setting-admin ' ,
180
209
'sunflower_layout ' ,
181
- array ( 'sunflower_categories_filter ' , __ ( 'Show list of categories on category archive ' , 'sunflower ' ) )
210
+ array (
211
+ 'field ' => 'sunflower_schema_org ' ,
212
+ 'label ' => __ ( 'Set website name in page metadata ' , 'sunflower ' ),
213
+ )
182
214
);
183
215
}
184
216
@@ -217,8 +249,8 @@ public function print_section_info() {
217
249
* @param array $args The field arguments.
218
250
*/
219
251
public function sunflower_checkbox_callback ( $ args ): void {
220
- $ field = $ args [0 ];
221
- $ label = $ args [1 ];
252
+ $ field = $ args [' field ' ];
253
+ $ label = $ args [' label ' ];
222
254
223
255
printf (
224
256
'<label>
0 commit comments