general changes

This commit is contained in:
2024-07-16 01:00:43 -07:00
parent 0f9e1492cc
commit 2da6388725
3 changed files with 14 additions and 14 deletions

View File

@ -14,45 +14,44 @@
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="https://gmpg.org/xfn/11">
<?php
$author_id = get_option('sophia_after_dark_home_og_user', 1); // Default to user ID 1 if not set
<?php
$author_id = get_option('sophia_after_dark_home_og_user', 1); // Default to user ID 1 if not set
$author_bio = get_the_author_meta('description', $author_id);
echo '<meta charset="' . get_bloginfo('charset') . '">' . "\n";
echo '<meta name="viewport" content="width=device-width, initial-scale=1">' . "\n";
if (is_front_page()) {
$home_og_image = get_option('sophia_after_dark_home_og_image');
if ($home_og_image) {
echo '<meta property="og:image" content="' . esc_url($home_og_image) . '" />' . "\n";
echo '<meta property="og:image" content="' . esc_url($home_og_image) . '" />' . "\n";
}
echo '<meta property="og:title" content="' . esc_attr(get_bloginfo('name') . ' - ' . get_bloginfo('description')) . '" />' . "\n";
echo '<meta property="og:description" content="' . esc_attr($author_bio) . '" />' . "\n";
echo '<meta property="og:url" content="' . esc_url(home_url('/')) . '" />' . "\n";
} elseif (is_single() || is_page()) {
global $post;
if (has_post_thumbnail($post->ID)) {
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'og-image-size');
if ($thumbnail) {
echo '<meta property="og:image" content="' . esc_url($thumbnail[0]) . '" />' . "\n";
// Uncomment and adjust the following lines if needed
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'og-image-size');
if ($thumbnail) {
echo '<meta property="og:image" content="' . esc_url($thumbnail[0]) . '" />' . "\n";
// $thumbnail_url = esc_url($thumbnail[0]);
// $thumbnail_parts = pathinfo($thumbnail_url);
// $thumbnail_new_url = $thumbnail_parts['dirname'] . '/' . $thumbnail_parts['filename'] . '-1536x878.' . $thumbnail_parts['extension'];
// echo '<meta property="og:image" content="' . $thumbnail_new_url . '" />' . "\n";
}
} else {
echo '<meta property="og:image" content="' . esc_url(get_template_directory_uri() . '/assets/images/default-og-image.webp') . '" />' . "\n";
echo '<meta property="og:image" content="' . esc_url(get_template_directory_uri() . '/assets/images/default-og-image.webp') . '" />' . "\n";
}
echo '<meta property="og:title" content="' . esc_attr(get_the_title()) . '" />' . "\n";
echo '<meta property="og:description" content="' . esc_attr(get_the_excerpt()) . '" />' . "\n";
echo '<meta property="og:url" content="' . esc_url(get_permalink()) . '" />' . "\n";
}
echo '<link rel="profile" href="https://gmpg.org/xfn/11">' . "\n";
wp_head();
?>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>

View File

@ -49,7 +49,7 @@ function sophia_after_dark_customize_general_panels_sections_register( $wp_custo
)
)
);
$wp_customize->add_control(new WP_Customize_Image_control(
$wp_customize->add_control(new Sophia_After_Dark_Image_control(
$wp_customize, 'sophia_after_dark_home_og_image', array(
'label' => __('Home Page Open Graph Image', 'sophia_after_dark'),
'section' => 'sophia_after_dark_section_site',

View File

@ -25,6 +25,7 @@ function sophia_after_dark_customize_register( $wp_customize ) {
$wp_customize->get_section( 'header_image' )->description = __( 'Header Image for only Innerpages', 'sophia-after-dark' );
$wp_customize->add_setting('sophia_after_dark_home_og_image', array('default' => '','sanitize_callback' => 'esc_url_raw','type' => 'option',));
$wp_customize->add_setting('sophia_after_dark_home_og_user', array('default' => 1,'sanitize_callback' => 'absint','type' => 'option',));
$wp_customize->add_setting('sophia_after_dark_mastodon', array('default' => 1,'sanitize_callback' => 'absint','type' => 'option',));
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'blogname', array(