Changeset 3289 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php
- Timestamp:
- 06/02/2016 06:55:49 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php
r3228 r3289 4 4 use WordPressdotorg\Plugin_Directory\Template; 5 5 use WordPressdotorg\Plugin_Directory\API\Base; 6 use WP_REST_Server; 6 7 7 8 /** … … 14 15 function __construct() { 15 16 register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/?', array( 16 'methods' => \WP_REST_Server::READABLE,17 'methods' => WP_REST_Server::READABLE, 17 18 'callback' => array( $this, 'plugin_info' ), 18 19 'args' => array( … … 31 32 */ 32 33 function plugin_info( $request ) { 33 /*34 * NOTE: Don't try to implement things such as the `fields` support in this endpoint.35 * It's highly unlikely we'll expose the REST API via api.wordpress.org as it is,36 * it'll probably have something in front of it.37 *38 * NOTE: Don't use any data from the client, such as the user_agent, just stick to what is presented in the GET payload.39 * It can't be cached if it's using data from other sources.40 */41 34 $plugin_slug = $request['plugin_slug']; 42 35 … … 76 69 $result['contributors'] = array(); 77 70 78 foreach ( (array)get_post_meta( $post_id, 'contributors', true ) as $contributor ) { 79 $user = get_user_by( 'slug', $contributor ); 71 $contributors = get_post_meta( $post_id, 'contributors', true ) ?: array( (int) $post->post_author ); 72 foreach ( $contributors as $contributor ) { 73 $user = is_int( $contributor ) ? get_user_by( 'id', $contributor ) : get_user_by( 'slug', $contributor ); 80 74 if ( ! $user ) { 81 75 continue; 82 76 } 83 77 84 $result['contributors'][ $ contributor] = array(78 $result['contributors'][ $user->user_nicename ] = array( 85 79 'profile' => $this->get_user_profile_link( $user ), 86 80 'avatar' => get_avatar_url( $user, array( 'default' => 'monsterid', 'rating' => 'g' ) ),
Note: See TracChangeset
for help on using the changeset viewer.