Making WordPress.org

Changeset 1337


Ignore:
Timestamp:
02/26/2015 10:05:12 PM (10 years ago)
Author:
obenland
Message:

WP.org Themes: Display parent theme information on the PHP side.

With the switch away from using the API, we have to manually set the required
fields for our requests. Since wp_parse_args() only parses one level deep,
this is a bit more verbose than usual.

See #745.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes
Files:
2 edited

Legend:

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

    r1278 r1337  
    2323            </div>
    2424
    25             <?php if ( ! empty( get_post()->parent ) ) : ?>
     25            <?php
     26                if ( ! empty( get_post()->post_parent ) ) :
     27                    $parent = get_post( get_post()->post_parent );
     28            ?>
    2629            <div class="theme-notice notice notice-info">
    27                 <p class="parent-theme"><?php printf( __( 'This is a child theme of %s.' ), sprintf( '<a href="/%1$s">%2$s</a>', $theme->parent->slug, $theme->parent->name ) ); ?></p>
     30                <p class="parent-theme"><?php printf( __( 'This is a child theme of %s.' ), sprintf( '<a href="%1$s">%2$s</a>', get_permalink( $parent->ID ), $parent->post_title ) ); ?></p>
    2831            </div>
    2932            <?php endif; ?>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php

    r1335 r1337  
    142142 */
    143143function wporg_themes_query_themes() {
    144     $args = wp_parse_args( wp_unslash( $_REQUEST['request'] ), array(
     144    $request = wp_unslash( $_REQUEST['request'] );
     145    $request['fields'] = wp_parse_args( $request['fields'], array(
     146        'description'  => true,
     147        'sections'     => false,
     148        'tested'       => true,
     149        'requires'     => true,
     150        'rating'       => true,
     151        'ratings'      => true,
     152        'downloaded'   => true,
     153        'downloadlink' => true,
     154        'last_updated' => true,
     155        'homepage'     => true,
     156        'tags'         => true,
     157        'num_ratings'  => true,
     158        'parent'       => true,
     159    ) );
     160    $args = wp_parse_args( $request, array(
    145161        'per_page' => 20,
    146         'fields'   => array(
    147             'description'  => true,
    148             'sections'     => false,
    149             'tested'       => true,
    150             'requires'     => true,
    151             'rating'       => true,
    152             'downloaded'   => true,
    153             'downloadlink' => true,
    154             'last_updated' => true,
    155             'homepage'     => true,
    156             'tags'         => true,
    157             'num_ratings'  => true,
    158         ),
    159162    ) );
    160163
     
    177180
    178181function wporg_themes_theme_info() {
    179     $args  = wp_unslash( $_REQUEST );
     182    $request = wp_unslash( $_REQUEST['request'] );
     183    $request['fields'] = wp_parse_args( $request['fields'], array(
     184        'description'  => true,
     185        'sections'     => false,
     186        'tested'       => true,
     187        'requires'     => true,
     188        'rating'       => true,
     189        'ratings'      => true,
     190        'downloaded'   => true,
     191        'downloadlink' => true,
     192        'last_updated' => true,
     193        'homepage'     => true,
     194        'tags'         => true,
     195        'num_ratings'  => true,
     196        'parent'       => true,
     197    ) );
    180198
    181199    include_once API_WPORGPATH . 'themes/info/1.0/class-themes-api.php';
    182     $api = new Themes_API( 'query_themes', array( 'slug' => $args['slug'] ) );
     200    $api = new Themes_API( 'theme_information', $request );
    183201    $api = $api->response;
    184202
    185     if ( is_wp_error( $api ) ) {
     203    if ( empty( $api ) ) {
    186204        wp_send_json_error();
    187205    }
Note: See TracChangeset for help on using the changeset viewer.