Making WordPress.org


Ignore:
Timestamp:
12/08/2016 01:58:37 PM (7 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/plugins/plugin-directory/api/routes/class-plugin.php

    r4458 r4505  
    1414class Plugin extends Base {
    1515
     16    /**
     17     * Plugin constructor.
     18     */
    1619    function __construct() {
    1720        register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/?', array(
     
    124127        foreach ( $screen_shots as $image ) {
    125128            $result['screenshots'][ $image['resolution'] ] = array(
    126                 'src'     => Template::get_asset_url( $post->post_name, $image ),
     129                'src'     => Template::get_asset_url( $post, $image ),
    127130                'caption' => array_key_exists( $image['resolution'], $descriptions ) ? $descriptions[ $image['resolution'] ] : ''
    128131            );
Note: See TracChangeset for help on using the changeset viewer.