$name, 'description' => clanfront_setting( 'tagline' ), 'image' => clanfront_setting( 'hero_image' ), 'url' => home_url( '/' ), 'type' => 'website', ); $post = get_queried_object(); if ( 'single-member' === $view && $post instanceof WP_Post ) { $role = trim( (string) get_post_meta( $post->ID, 'clanfront_role', true ) ); $games = trim( (string) get_post_meta( $post->ID, 'clanfront_games', true ) ); $bits = array_filter( array( $role, $games ) ); $data['title'] = get_the_title( $post ) . ' – ' . $name; $data['description'] = $bits ? implode( ' · ', $bits ) : 'A member of ' . $name; $data['url'] = get_permalink( $post ); $data['type'] = 'profile'; if ( has_post_thumbnail( $post ) ) { $data['image'] = get_the_post_thumbnail_url( $post, 'large' ); } } elseif ( 'single-match' === $view && $post instanceof WP_Post ) { $game = trim( (string) get_post_meta( $post->ID, 'clanfront_game', true ) ); $data['title'] = get_the_title( $post ) . ' – ' . $name; $data['description'] = trim( clanfront_event_kind_label( $post ) . ( $game ? ' · ' . $game : '' ) . ' · ' . clanfront_event_when( $post ), ' ·' ); $data['url'] = get_permalink( $post ); } elseif ( 'single-news' === $view && $post instanceof WP_Post ) { $data['title'] = get_the_title( $post ) . ' – ' . $name; $data['description'] = clanfront_news_summary( $post ); $data['url'] = get_permalink( $post ); $data['type'] = 'article'; if ( has_post_thumbnail( $post ) ) { $data['image'] = get_the_post_thumbnail_url( $post, 'large' ); } } elseif ( 'single-tournament' === $view && $post instanceof WP_Post ) { $game = trim( (string) get_post_meta( $post->ID, 'clanfront_game', true ) ); $data['title'] = get_the_title( $post ) . ' – ' . $name; $data['description'] = 'Tournament' . ( $game ? ' · ' . $game : '' ) . ' · ' . clanfront_tourney_status( $post ); $data['url'] = get_permalink( $post ); } elseif ( 'single-game' === $view && $post instanceof WP_Post ) { $note = trim( (string) get_post_meta( $post->ID, 'clanfront_note', true ) ); $data['title'] = get_the_title( $post ) . ' – ' . $name; $data['description'] = $note ? $note : get_the_title( $post ) . ' with ' . $name . '.'; $data['url'] = get_permalink( $post ); if ( has_post_thumbnail( $post ) ) { $data['image'] = get_the_post_thumbnail_url( $post, 'large' ); } } elseif ( 'archive-game' === $view ) { $data['title'] = 'Games – ' . $name; $data['description'] = 'The games ' . $name . ' plays.'; $data['url'] = get_post_type_archive_link( 'clanfront_game' ); } elseif ( 'archive-shame' === $view ) { $data['title'] = 'Hall of Shame – ' . $name; $data['description'] = 'The finest friendly-fire moments of ' . $name . '.'; $data['url'] = get_post_type_archive_link( 'clanfront_shame' ); } elseif ( 'archive-history' === $view ) { $data['title'] = 'History – ' . $name; $data['description'] = 'The story of ' . $name . ', milestone by milestone.'; $data['url'] = get_post_type_archive_link( 'clanfront_milestone' ); } elseif ( 'archive-member' === $view ) { $data['title'] = 'Roster – ' . $name; $data['description'] = 'Meet the members of ' . $name . '.'; $data['url'] = get_post_type_archive_link( 'clanfront_member' ); } elseif ( 'archive-match' === $view ) { $data['title'] = 'Matches – ' . $name; $data['description'] = 'Schedule and results for ' . $name . '.'; $data['url'] = get_post_type_archive_link( 'clanfront_match' ); } elseif ( 'archive-media' === $view ) { $data['title'] = 'Gallery – ' . $name; $data['description'] = 'Screenshots and highlight clips from ' . $name . '.'; $data['url'] = get_post_type_archive_link( 'clanfront_media' ); } elseif ( 'archive-news' === $view ) { $data['title'] = 'News – ' . $name; $data['description'] = 'The latest news from ' . $name . '.'; $data['url'] = get_post_type_archive_link( 'clanfront_news' ); } elseif ( 'archive-tournament' === $view ) { $data['title'] = 'Tournaments – ' . $name; $data['description'] = 'Tournaments and brackets from ' . $name . '.'; $data['url'] = get_post_type_archive_link( 'clanfront_tourney' ); } elseif ( $post instanceof WP_Post && 'page' === $post->post_type && 'home' !== $view ) { $text = wp_trim_words( wp_strip_all_tags( strip_shortcodes( $post->post_content ) ), 30 ); $data['title'] = get_the_title( $post ) . ' – ' . $name; if ( '' !== $text ) { $data['description'] = $text; } $data['url'] = get_permalink( $post ); } if ( '' === (string) $data['description'] && '' !== (string) $logo ) { $data['description'] = $name; } $data['image'] = clanfront_absolute_url( clanfront_local_url( $data['image'] ) ); $data['description'] = wp_strip_all_tags( (string) $data['description'] ); return apply_filters( 'clanfront_share_data', $data ); } add_action( 'wp_head', function () { if ( ! function_exists( 'clanfront_view' ) || ! clanfront_view() ) { return; } $d = clanfront_share_data(); $tags = array( array( 'property', 'og:site_name', clanfront_name() ), array( 'property', 'og:type', $d['type'] ), array( 'property', 'og:title', $d['title'] ), array( 'property', 'og:description', $d['description'] ), array( 'property', 'og:url', $d['url'] ), array( 'name', 'twitter:card', $d['image'] ? 'summary_large_image' : 'summary' ), array( 'name', 'twitter:title', $d['title'] ), array( 'name', 'twitter:description', $d['description'] ), array( 'name', 'description', $d['description'] ), ); if ( $d['image'] ) { $tags[] = array( 'property', 'og:image', $d['image'] ); $tags[] = array( 'name', 'twitter:image', $d['image'] ); } foreach ( $tags as $t ) { if ( '' === (string) $t[2] ) { continue; } printf( '' . "\n", esc_attr( $t[0] ), esc_attr( $t[1] ), esc_attr( $t[2] ) ); } }, 5 ); // Stop offering WordPress's own embed card (the one that shows the author name) on these pages. add_action( 'wp', function () { if ( function_exists( 'clanfront_view' ) && clanfront_view() ) { remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); } } ); // Never reveal a username through the embed data either. add_filter( 'oembed_response_data', function ( $data ) { unset( $data['author_name'], $data['author_url'] ); return $data; } ); /* ---------- Author privacy ---------- */ // Author pages (/author/admin/, ?author=1) list a username and use the plain theme. A clan site has no use for them. add_action( 'template_redirect', function () { if ( is_author() ) { wp_safe_redirect( home_url( '/' ), 301 ); exit; } }, 1 ); // Keep usernames out of the XML sitemap too. add_filter( 'wp_sitemaps_add_provider', function ( $provider, $name ) { return 'users' === $name ? false : $provider; }, 10, 2 );