Making WordPress.org

Changeset 2908


Ignore:
Timestamp:
04/06/2016 02:35:44 PM (6 years ago)
Author:
ocean90
Message:

Theme Directory: Add Open Graph meta data and meta tags for Twitter cards to theme pages.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r2755 r2908  
    290290 *
    291291 * Note: nonce protected, only available to logged in users
    292  * 
    293  * While this user search is a bit heavy because of the SQL to search the whole users table, 
     292 *
     293 * While this user search is a bit heavy because of the SQL to search the whole users table,
    294294 * it's not one that we will actually run a lot. This only occurs when a theme directory admin
    295  * is changing the "author" of a theme. This is fairly rare. If the query causes too many issues, 
     295 * is changing the "author" of a theme. This is fairly rare. If the query causes too many issues,
    296296 * then we can refine it to limit it more.
    297297 */
     
    307307    );
    308308    $user_query = new WP_User_Query( $args );
    309    
     309
    310310    if ( $user_query->results ) {
    311311        $resp = array();
     
    317317        echo json_encode($resp);
    318318    }
    319     exit;   
     319    exit;
    320320}
    321321add_action('wp_ajax_author-lookup', 'wporg_themes_author_lookup');
     
    994994
    995995/**
     996 * Prints Open Graph meta data and meta tags for Twitter cards.
     997 */
     998function wporg_themes_add_meta_tags() {
     999    if ( ! is_single() ) {
     1000        return;
     1001    }
     1002
     1003    $post = get_post();
     1004    if ( ! $post ) {
     1005        return;
     1006    }
     1007
     1008    $theme = wporg_themes_theme_information( $post->post_name );
     1009    if ( ! $theme ) {
     1010        return;
     1011    }
     1012
     1013    echo "<meta property='og:title' content='" . esc_attr( $theme->name ) . "' />\n";
     1014    echo "<meta property='og:description' content='" . esc_attr( $theme->description ) . "' />\n";
     1015    echo "<meta property='og:site_name' content='WordPress.org' />\n";
     1016    echo "<meta property='og:type' content='website' />\n";
     1017    echo "<meta property='og:url' content='" . esc_attr( get_permalink( $post->id ) ) . "' />\n";
     1018
     1019    if ( $theme->screenshot_url ) {
     1020        echo "<meta property='og:image' content='" . esc_attr( $theme->screenshot_url ) . "' />\n";
     1021        echo "<meta name='twitter:card' content='summary_large_image'>\n";
     1022        echo "<meta name='twitter:site' content='@WordPress'>\n";
     1023        echo "<meta name='twitter:image' content='" . esc_attr( $theme->screenshot_url . '?w=560&amp;strip=all' ) . "' />\n";
     1024    }
     1025}
     1026add_action( 'wp_head', 'wporg_themes_add_meta_tags' );
     1027
     1028/**
    9961029 * Filter the URLs to use the current localized domain name, rather than WordPress.org.
    9971030 *
Note: See TracChangeset for help on using the changeset viewer.