Making WordPress.org

Ticket #3587: 3587.diff

File 3587.diff, 1.8 KB (added by valentinbora, 7 years ago)

Add og:image and a few other social meta tags

  • wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php
    index c72801f17..d7b902ea2 100644
    function wporg_get_global_header() {  
    191191        $GLOBALS['pagetitle'] = wp_title( '|', false, 'right' );
    192192        // Suffix either "WordPress.org $LOCALE" or WordPress.org.
    193193        if ( isset( $GLOBALS['wporg_global_header_options']['rosetta_title'] ) ) {
    194                 $GLOBALS['pagetitle'] .= $GLOBALS['wporg_global_header_options']['rosetta_title'];
     194                $GLOBALS['sitename'] = $GLOBALS['wporg_global_header_options']['rosetta_title'];
    195195        } else {
    196                 $GLOBALS['pagetitle'] .= __( 'WordPress.org', 'wporg-forums' );
     196                $GLOBALS['sitename'] = __( 'WordPress.org', 'wporg-forums' );
    197197        }
    198198
     199        $GLOBALS['pagetitle'] .= $GLOBALS['sitename'];
     200
    199201        require WPORGPATH . 'header.php';
    200202}
    201203
     204add_action( 'wp_head', 'wporg_add_og_meta_tags' );
     205
     206/**
     207 * Add social sharing meta tags via wp_head
     208 *
     209 * @package WPBBP
     210 **/
     211function wporg_add_og_meta_tags() {
     212        $title = trim( wp_title( '', false, '' ) );
     213        ?>
     214<meta property="og:title" content="<?php echo $title ?>" />
     215<meta property="og:image" content="https://s.w.org/images/backgrounds/wordpress-bg-medblue.png" />
     216<meta property="og:site_name" content="<?php echo $GLOBALS['sitename'] ?>" />
     217
     218<meta name="twitter:image" content="https://s.w.org/images/backgrounds/wordpress-bg-medblue-square.png" />
     219<meta name="twitter:text:title" content="<?php echo $title ?>" />
     220        <?php
     221}
     222
    202223function wporg_support_bbp_raw_title( $title ) {
    203224        if ( get_query_var( 'paged' ) && ! is_404() ) {
    204225                $title .= sprintf( ' - page %s', get_query_var( 'paged' ) );