Bump to 1.4.0, made some fixes for 8.2+

This commit is contained in:
2025-05-11 16:58:27 -07:00
parent 75cbf48af8
commit 5fd30040a4
14 changed files with 428 additions and 439 deletions

View File

@ -14,130 +14,76 @@
<!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
$author_bio = get_the_author_meta('description', $author_id);
// Set default author for home page OG metadata
$author_id = (int) get_option( 'sophia_after_dark_home_og_user', 1 );
$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 (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: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";
// $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: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";
if ( $home_og_image ) {
printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $home_og_image ) );
}
echo '<link rel="profile" href="https://gmpg.org/xfn/11">' . "\n";
wp_head();
printf( '<meta property="og:title" content="%s" />' . "\n", esc_attr( get_bloginfo( 'name' ) . ' - ' . get_bloginfo( 'description' ) ) );
printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( $author_bio ) );
printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( home_url( '/' ) ) );
} elseif ( is_singular() ) {
global $post;
$thumbnail_url = get_template_directory_uri() . '/assets/images/default-og-image.webp';
if ( has_post_thumbnail( $post?->ID ) ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'og-image-size' );
if ( ! empty( $image[0] ) ) {
$thumbnail_url = $image[0];
}
}
printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $thumbnail_url ) );
printf( '<meta property="og:title" content="%s" />' . "\n", esc_attr( get_the_title() ) );
printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( get_the_excerpt() ) );
printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( get_permalink() ) );
}
wp_head();
?>
</head>
<body <?php body_class(); ?>>
<?php
if ( function_exists( 'wp_body_open' ) ) {
wp_body_open();
} else {
/**
* Hook: wp_body_open
*
* @since 1.1.0
*/
do_action( 'wp_body_open' );
}
if ( function_exists( 'wp_body_open' ) ) {
wp_body_open();
} else {
do_action( 'wp_body_open' ); // Backwards compatibility for < WP 5.2
}
/**
* sophia_after_dark before page hook
*
* @since 1.0.0
*/
do_action( 'sophia_after_dark_before_page' );
do_action( 'sophia_after_dark_before_page' );
?>
<div id="page" class="site">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip To Content', 'sophia-after-dark' ) ?></a>
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'sophia-after-dark' ); ?></a>
<?php
/**
* sophia_after_dark before header
*
* @since 1.0.0
*/
do_action( 'sophia_after_dark_before_header' );
// Top Header
if ( get_theme_mod( 'sophia_after_dark_enable_top_header', true ) ) {
do_action( 'sophia_after_dark_top_header' );
}
$sophia_after_dark_enable_top_header = get_theme_mod( 'sophia_after_dark_enable_top_header', true );
if ( true === $sophia_after_dark_enable_top_header ) {
/**
* hook - sophia_after_dark_top_header
*
* @hooked - sophia_after_dark_top_header_start - 5
* @hooked - sophia_after_dark_trending_section - 10
* @hooked - sophia_after_dark_top_header_nav - 20
* @hooked - sophia_after_dark_top_header_end - 50
*/
do_action( 'sophia_after_dark_top_header' );
}
// Main Header
do_action( 'sophia_after_dark_main_header' );
/**
* sophia_after_dark main header
*
* @hooked - sophia_after_dark_main_header_start - 5
* @hooked - sophia_after_dark_site_branding - 10
* @hooked - sophia_after_dark_menu_wrapper_start - 15
* @hooked - sophia_after_dark_header_main_menu - 20
* @hooked - sophia_after_dark_menu_icon_wrapper_start - 25
* @hooked - sophia_after_dark_menu_social_icons - 30
* @hooked - sophia_after_dark_menu_search_icon - 35
* @hooked - sophia_after_dark_menu_icon_wrapper_end - 40
* @hooked - sophia_after_dark_menu_wrapper_end - 45
* @hooked - sophia_after_dark_main_header_end - 50
*
* @since 1.0.0
*/
do_action( 'sophia_after_dark_main_header' );
if ( is_front_page() ) {
/**
* hook - front_slider_section
* displays front top section before archive blogs.
*/
do_action( 'sophia_after_dark_front_slider_section' );
}
if ( ! is_front_page() ) {
/**
* sophia_after_dark_innerpage_header hook
*
* @hooked - sophia_after_dark_innerpage_header_start - 5
* @hooked - sophia_after_dark_innerpage_header_title - 10
* @hooked - sophia_after_dark_breadcrumb_content - 15
* @hooked - sophia_after_dark_innerpage_header_end - 20
*
* @since 1.0.0
*/
do_action( 'sophia_after_dark_innerpage_header' );
}
// Front page slider or inner page header
if ( is_front_page() ) {
do_action( 'sophia_after_dark_front_slider_section' );
} else {
do_action( 'sophia_after_dark_innerpage_header' );
}
?>
<div id="content" class="site-content">