Making WordPress.org


Ignore:
Timestamp:
12/08/2016 01:58:37 PM (10 years ago)
Author:
obenland
Message:

Plugin Directory: Use get_post() for template functions.

Template functions should fall back to the global post object.
Also fixes a bug where assets weren't loaded correctly while in the loop.

Props joostdevalk for initial patch.
Fixes #2303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php

    r4504 r4505  
    164164        }
    165165
    166         $post_id = get_the_ID();
    167         $banner  = Template::get_plugin_banner( $post_id );
     166        $banner  = Template::get_plugin_banner();
    168167        $banner['banner_2x'] = $banner['banner_2x'] ? $banner['banner'] : false;
    169         $icon = Template::get_plugin_icon( $post_id );
    170 
    171         printf( '<meta property="og:title" content="%s" />' . "\n", the_title_attribute( array( 'echo' => false, 'post' => $post_id ) ) );
    172         printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( strip_tags( get_the_excerpt( $post_id ) ) ) );
     168        $icon = Template::get_plugin_icon();
     169
     170        printf( '<meta property="og:title" content="%s" />' . "\n", the_title_attribute( array( 'echo' => false ) ) );
     171        printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( strip_tags( get_the_excerpt() ) ) );
    173172        printf( '<meta property="og:site_name" content="WordPress.org" />' . "\n" );
    174173        printf( '<meta property="og:type" content="website" />' . "\n" );
    175         printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( get_permalink( $post_id ) ) );
     174        printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( get_permalink() ) );
    176175        printf( '<meta name="twitter:card" content="summary_large_image">' . "\n" );
    177176        printf( '<meta name="twitter:site" content="@WordPress">' . "\n" );
    178177
    179178        if ( $banner['banner_2x'] ) {
    180                 printf( '<meta name="twitter:image" content="%s" />' . "\n", $banner['banner_2x'] );
     179                printf( '<meta name="twitter:image" content="%s" />' . "\n", esc_url( $banner['banner_2x'] ) );
    181180        }
    182181        if ( isset( $banner['banner'] ) ) {
    183                 printf( '<meta property="og:image" content="%s" />' . "\n", $banner['banner'] );
     182                printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $banner['banner'] ) );
    184183        }
    185184        if ( ! $icon['generated'] && ( $icon['icon_2x'] || $icon['icon'] ) ) {
    186                 printf( '<meta name="thumbnail" content="%s" />', $icon['icon_2x'] ?: $icon['icon'] );
     185                printf( '<meta name="thumbnail" content="%s" />' . "\n", esc_url( $icon['icon_2x'] ?: $icon['icon'] ) );
    187186        }
    188187}
Note: See TracChangeset for help on using the changeset viewer.