Skip to content

Commit

Permalink
Show websitename in page metadata to enhance SEO (search engine optim…
Browse files Browse the repository at this point in the history
…ization) (#718)
  • Loading branch information
albig authored Sep 3, 2024
1 parent 45c456b commit f212aa1
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 115 deletions.
1 change: 0 additions & 1 deletion assets/js/custom-jquery-date-time-picker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-undef */

jQuery( function ( $ ) {
$.datetimepicker.setLocale( 'de' );

Expand Down
46 changes: 39 additions & 7 deletions functions/options/class-sunflowersettingspage.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public function sunflower_add_plugin_page(): void {
public function create_sunflower_settings_page(): void {
// Set class properties from options.
$this->options = get_option( 'sunflower_options' );

if ( ! is_array( $this->options ) ) {
$this->options = array();
}

// Set default values.
$this->options['sunflower_schema_org'] = $this->options['sunflower_schema_org'] ?? 'checked';
$this->options['sunflower_categories_archive'] = $this->options['sunflower_categories_archive'] ?? 'main-categories';

?>
<div class="wrap">
<h1><?php esc_html_e( 'Sunflower Settings', 'sunflower' ); ?></h1>
Expand Down Expand Up @@ -115,7 +124,10 @@ public function sunflower_settings_page_init(): void {
$this->sunflower_checkbox_callback( ... ),
'sunflower-setting-admin',
'sunflower_layout',
array( 'sunflower_show_related_posts', __( 'show related posts', 'sunflower' ) )
array(
'field' => 'sunflower_show_related_posts',
'label' => __( 'show related posts', 'sunflower' ),
)
);

add_settings_field(
Expand All @@ -124,7 +136,10 @@ public function sunflower_settings_page_init(): void {
$this->sunflower_checkbox_callback( ... ),
'sunflower-setting-admin',
'sunflower_layout',
array( 'sunflower_show_author', __( 'Show post author on post details and via REST api.', 'sunflower' ) )
array(
'field' => 'sunflower_show_author',
'label' => __( 'Show post author on post details and via REST api.', 'sunflower' ),
)
);

add_settings_field(
Expand All @@ -133,7 +148,10 @@ public function sunflower_settings_page_init(): void {
$this->sunflower_checkbox_callback( ... ),
'sunflower-setting-admin',
'sunflower_layout',
array( 'sunflower_hide_prev_next', __( 'hide previous and next links', 'sunflower' ) )
array(
'field' => 'sunflower_hide_prev_next',
'label' => __( 'hide previous and next links', 'sunflower' ),
)
);

add_settings_field(
Expand All @@ -151,7 +169,10 @@ public function sunflower_settings_page_init(): void {
$this->sunflower_checkbox_callback( ... ),
'sunflower-setting-admin',
'sunflower_layout',
array( 'sunflower_main_menu_item_is_placeholder', __( 'items with href=# in the main menu are placeholders for submenu', 'sunflower' ) )
array(
'field' => 'sunflower_main_menu_item_is_placeholder',
'label' => __( 'items with href=# in the main menu are placeholders for submenu', 'sunflower' ),
)
);

add_settings_field(
Expand All @@ -177,8 +198,19 @@ public function sunflower_settings_page_init(): void {
__( 'Show list of categories on category archive', 'sunflower' ),
$this->sunflower_categories_archive( ... ),
'sunflower-setting-admin',
'sunflower_layout'
);

add_settings_field(
'sunflower_schema_org',
__( 'Enhance SEO', 'sunflower' ),
$this->sunflower_checkbox_callback( ... ),
'sunflower-setting-admin',
'sunflower_layout',
array( 'sunflower_categories_filter', __( 'Show list of categories on category archive', 'sunflower' ) )
array(
'field' => 'sunflower_schema_org',
'label' => __( 'Set website name in page metadata', 'sunflower' ),
)
);
}

Expand Down Expand Up @@ -217,8 +249,8 @@ public function print_section_info() {
* @param array $args The field arguments.
*/
public function sunflower_checkbox_callback( $args ): void {
$field = $args[0];
$label = $args[1];
$field = $args['field'];
$label = $args['label'];

printf(
'<label>
Expand Down
Binary file modified languages/de_DE.mo
Binary file not shown.
Loading

0 comments on commit f212aa1

Please sign in to comment.