Changeset 6485
- Timestamp:
- 01/31/2018 04:08:51 AM (7 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php
r6287 r6485 91 91 } 92 92 return null; 93 } 94 95 public function __set( $field, $value ) { 96 $this->args->{$field} = $value; 97 } 98 99 public function __unset( $field ) { 100 unset( $this->args->{$field} ); 93 101 } 94 102 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api.php
r6464 r6485 62 62 63 63 /** 64 * API Endpoint that handles the Plugin_Information route when the 'slugs' parameter is present. 65 * 66 * @param Plugins_Info_API_Request $request The Request object for this request. 67 */ 68 function plugin_information_mutliple( $request ) { 69 $slugs = is_array( $request->slugs ) ? $request->slugs : explode( ',', $request->slugs ); 70 $slugs = array_unique( array_map( 'trim', $slugs ) ); 71 72 if ( count( $slugs ) > 100 ) { 73 $this->output( (object) array( 'error' => 'A maximum of 100 plugins can be queried at once.' ) ); 74 return; 75 } 76 77 // Remove the slugs parameter to avoid recursive calls. 78 unset( $request->slugs ); 79 80 $response = array(); 81 foreach ( $slugs as $slug ) { 82 $request->slug = $slug; 83 $plugin_details = $this->plugin_information( $request, $return_raw = true ); 84 if ( ! isset( $plugin_details['error'] ) ) { 85 $plugin_details = $this->remove_unexpected_fields( $plugin_details, $request, 'plugin_information' ); 86 } 87 88 $response[ $slug ] = $plugin_details; 89 } 90 91 $this->output( (object) $response ); 92 } 93 94 /** 64 95 * API Endpoint that handles the Plugin_Information route. 65 96 * … … 68 99 */ 69 100 function plugin_information( $request, $return_raw = false ) { 70 if ( false === ( $response = wp_cache_get( $cache_key = $this->plugin_information_cache_key( $request ), self::CACHE_GROUP ) ) ) { 101 if ( $request->slugs ) { 102 $this->plugin_information_mutliple( $request ); 103 return; 104 } 105 106 $response = false; 107 if ( ! $request->slug ) { 108 $response = array( 'error' => 'Plugin slug not provided.' ); 109 } 110 111 if ( ! $response && false === ( $response = wp_cache_get( $cache_key = $this->plugin_information_cache_key( $request ), self::CACHE_GROUP ) ) ) { 71 112 $response = $this->internal_rest_api_call( 'plugins/v1/plugin/' . $request->slug, array( 'locale' => $request->locale ) ); 72 113
Note: See TracChangeset
for help on using the changeset viewer.