' . "\n"; } $type = is_singular( 'post' ) ? 'article' : 'website'; $title = wp_get_document_title(); $image = site_identity_image(); echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; if ( '' !== $url ) { echo '' . "\n"; } if ( '' !== $image ) { echo '' . "\n"; } $description = is_singular() ? get_the_excerpt() : get_bloginfo( 'description' ); $description = markdown_safe_text( (string) $description ); if ( '' !== $description ) { echo '' . "\n"; } } /** * Canonical URL of the current view ('' when it cannot be determined). * * @return string */ function current_canonical_url(): string { if ( is_front_page() ) { return home_url( '/' ); } if ( is_singular() ) { $permalink = get_permalink(); return is_string( $permalink ) ? $permalink : ''; } if ( is_home() ) { $posts_page = (int) get_option( 'page_for_posts' ); $link = $posts_page > 0 ? get_permalink( $posts_page ) : home_url( '/' ); return is_string( $link ) ? $link : ''; } if ( is_category() || is_tag() || is_tax() ) { $link = get_term_link( get_queried_object() ); return is_string( $link ) ? $link : ''; } if ( is_post_type_archive() ) { $link = get_post_type_archive_link( (string) get_query_var( 'post_type' ) ); return is_string( $link ) ? $link : ''; } if ( is_author() ) { $link = get_author_posts_url( (int) get_query_var( 'author' ) ); return is_string( $link ) ? $link : ''; } return ''; } /** * Best available image for the current view: featured image on singular, * else the theme's custom logo, else the site icon. * * @return string */ function site_identity_image(): string { if ( is_singular() ) { $thumb = get_the_post_thumbnail_url( null, 'large' ); if ( is_string( $thumb ) && '' !== $thumb ) { return $thumb; } } $logo_id = (int) get_theme_mod( 'custom_logo' ); if ( $logo_id > 0 ) { $logo = wp_get_attachment_image_url( $logo_id, 'full' ); if ( is_string( $logo ) && '' !== $logo ) { return $logo; } } $icon = get_site_icon_url( 512 ); return is_string( $icon ) ? $icon : ''; }