Skip to content

Commit 3a397ba

Browse files
committed
Show websitename in page metadata to enhance SEO (search engine optimization)
1 parent 45c456b commit 3a397ba

File tree

7 files changed

+197
-115
lines changed

7 files changed

+197
-115
lines changed

assets/js/custom-jquery-date-time-picker.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable no-undef */
2-
32
jQuery( function ( $ ) {
43
$.datetimepicker.setLocale( 'de' );
54

functions/options/class-sunflowersettingspage.php

+39-7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ public function sunflower_add_plugin_page(): void {
4545
public function create_sunflower_settings_page(): void {
4646
// Set class properties from options.
4747
$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+
4857
?>
4958
<div class="wrap">
5059
<h1><?php esc_html_e( 'Sunflower Settings', 'sunflower' ); ?></h1>
@@ -115,7 +124,10 @@ public function sunflower_settings_page_init(): void {
115124
$this->sunflower_checkbox_callback( ... ),
116125
'sunflower-setting-admin',
117126
'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+
)
119131
);
120132

121133
add_settings_field(
@@ -124,7 +136,10 @@ public function sunflower_settings_page_init(): void {
124136
$this->sunflower_checkbox_callback( ... ),
125137
'sunflower-setting-admin',
126138
'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+
)
128143
);
129144

130145
add_settings_field(
@@ -133,7 +148,10 @@ public function sunflower_settings_page_init(): void {
133148
$this->sunflower_checkbox_callback( ... ),
134149
'sunflower-setting-admin',
135150
'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+
)
137155
);
138156

139157
add_settings_field(
@@ -151,7 +169,10 @@ public function sunflower_settings_page_init(): void {
151169
$this->sunflower_checkbox_callback( ... ),
152170
'sunflower-setting-admin',
153171
'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+
)
155176
);
156177

157178
add_settings_field(
@@ -177,8 +198,19 @@ public function sunflower_settings_page_init(): void {
177198
__( 'Show list of categories on category archive', 'sunflower' ),
178199
$this->sunflower_categories_archive( ... ),
179200
'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',
180209
'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+
)
182214
);
183215
}
184216

@@ -217,8 +249,8 @@ public function print_section_info() {
217249
* @param array $args The field arguments.
218250
*/
219251
public function sunflower_checkbox_callback( $args ): void {
220-
$field = $args[0];
221-
$label = $args[1];
252+
$field = $args['field'];
253+
$label = $args['label'];
222254

223255
printf(
224256
'<label>

languages/de_DE.mo

-19 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)