__( 'Primary navigation', 'chrnx' ), 'chrnx-footer' => __( 'Footer navigation', 'chrnx' ), ) ); // No template renders a comment thread, so nothing is collected silently. remove_post_type_support( 'post', 'comments' ); remove_post_type_support( 'page', 'comments' ); } add_action( 'after_setup_theme', 'chrnx_setup' ); add_filter( 'comments_open', '__return_false' ); /** * Print Open Graph and Twitter card tags only when nothing else does. * * ponytail: an installed SEO plugin already emits these per post, with the * right title and image. Two sets of og: tags let crawlers pick the wrong one, * so the theme yields and only covers the no-plugin case. */ function chrnx_print_social_meta() { if ( chrnx_has_seo_plugin() ) { return; } if ( is_singular() ) { $title = get_the_title(); $url = get_permalink(); $description = wp_strip_all_tags( get_the_excerpt() ); $type = 'article'; $image_id = get_post_thumbnail_id(); } else { $title = get_bloginfo( 'name' ); $url = home_url( '/' ); $description = get_bloginfo( 'description' ); $type = 'website'; $image_id = 0; } // Generated derivative, not the design master: masters are not shipped. $image = $image_id ? wp_get_attachment_image_url( $image_id, 'full' ) : get_theme_file_uri( 'assets/images/generated/about-grunge-1536.webp' ); $tags = array( 'og:site_name' => get_bloginfo( 'name' ), 'og:type' => $type, 'og:title' => $title, 'og:description' => $description, 'og:url' => $url, 'og:image' => $image, ); foreach ( $tags as $property => $content ) { if ( '' === $content ) { continue; } printf( '' . "\n", esc_attr( $property ), esc_attr( $content ) ); } echo '' . "\n"; } add_action( 'wp_head', 'chrnx_print_social_meta' ); /** * Report whether an SEO plugin already printed the document head. * * Deliberately not "is one installed": Rank Math skips its whole frontend * until its setup wizard completes, so an installed-but-silent plugin used to * make the theme yield to nobody. rank_math/head fires only when it really * rendered, and it runs at wp_head priority 1, ahead of the tags below. * * @return bool True when an SEO plugin printed its head block. */ function chrnx_has_seo_plugin(): bool { return did_action( 'rank_math/head' ) > 0; } /** * Drop the relocated copy of core's title tag. * * Rank Math moves _wp_render_title_tag off wp_head and into its own * rank_math/head block, but it does not know about the block-theme renderer * that replaced it, so block themes render two identical