Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new setting website name #724

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions functions/options/class-sunflowersettingspage.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public function create_sunflower_settings_page(): void {
$this->options = get_option( 'sunflower_options' );

if ( ! is_array( $this->options ) ) {
$this->options = array();
$this->options = array();
$this->options['sunflower_schema_org'] = $this->options['sunflower_schema_org'] ?? 'checked';
}

// 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';

?>
Expand Down
11 changes: 4 additions & 7 deletions template-parts/open-graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,14 @@
<meta name="twitter:image" content="<?php echo esc_url( $sunflower_open_graph_image ); ?>">

<?php
$sunflower_schema_org = sunflower_get_setting( 'sunflower_schema_org' );
if ( ! function_exists( 'is_plugin_active' ) ) {

$sunflower_is_yoast_active = defined( 'WPSEO_FILE' );
}
$sunflower_schema_org = sunflower_get_setting( 'sunflower_schema_org' );
$sunflower_is_yoast_active = defined( 'WPSEO_FILE' );

// Add WebSite schema. See https://developers.google.com/search/docs/appearance/site-names?hl=de#website for details.
// schema.org metadata may be set already by other plugins as Yoast.
if ( 'checked' === $sunflower_schema_org && false === $sunflower_is_yoast_active ) {

printf( '<meta property="og:site_name" content="%s">', esc_attr( get_bloginfo( 'name' ) ) );
printf( '<meta property="og:site_name" content="%s">' . "\n", esc_attr( get_bloginfo( 'name' ) ) );
printf(
'<script type="application/ld+json">
{
Expand All @@ -50,7 +47,7 @@
"name" : "%s",
"url" : "%s"
}
</script>',
</script>' . "\n",
esc_attr( get_bloginfo( 'name' ) ),
esc_url( get_home_url() )
);
Expand Down