Changeset 6287 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php
- Timestamp:
- 12/19/2017 04:22:37 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php
r5841 r6287 6 6 */ 7 7 class Plugins_Info_API_Request { 8 public $locale = 'en_US';9 protected $args = array();8 public $locale = 'en_US'; 9 protected $args = array(); 10 10 protected $requested_fields = array(); 11 11 … … 36 36 37 37 static $plugins_info_fields_defaults = array( 38 'added' => true,39 'compatibility' => true,40 'contributors' => true,41 'downloaded' => true,42 'downloadlink' => true,43 'donate_link' => true,44 'homepage' => true,45 'last_updated' => true,46 'rating' => true,47 'ratings' => true,48 'requires' => true,49 'requires_php' => true,50 'sections' => true,51 'tags' => true,52 'tested' => true,38 'added' => true, 39 'compatibility' => true, 40 'contributors' => true, 41 'downloaded' => true, 42 'downloadlink' => true, 43 'donate_link' => true, 44 'homepage' => true, 45 'last_updated' => true, 46 'rating' => true, 47 'ratings' => true, 48 'requires' => true, 49 'requires_php' => true, 50 'sections' => true, 51 'tags' => true, 52 'tested' => true, 53 53 ); 54 54 … … 64 64 'rating' => true, 65 65 'ratings' => true, 66 'requires' => true, 66 'requires' => true, 67 67 'requires_php' => true, 68 68 'sections' => true, … … 75 75 $args = (object) $args; 76 76 77 if ( ! empty( $args->locale ) ) {77 if ( ! empty( $args->locale ) ) { 78 78 $this->locale = $args->locale; // TODO: sanitize? 79 79 } 80 if ( ! empty( $args->fields ) ) {80 if ( ! empty( $args->fields ) ) { 81 81 $this->requested_fields = $this->parse_requested_fields( $args->fields ); 82 82 } … … 112 112 113 113 // In WordPress x.y we start sending 'contributors' which means respond with a more detailed list of contributors. 114 if ( ! isset( $this->requested_fields['contributors'] ) ) {114 if ( ! isset( $this->requested_fields['contributors'] ) ) { 115 115 $fields['bare_contributors'] = true; 116 116 } … … 122 122 123 123 /** 124 * Sanitizes/parses the given fields parameter into a standard format. 124 * Sanitizes/parses the given fields parameter into a standard format. 125 125 */ 126 126 protected function parse_requested_fields( $fields ) { 127 $fields = is_string( $fields ) ? explode( ',', $fields ) : (array) $fields;127 $fields = is_string( $fields ) ? explode( ',', $fields ) : (array) $fields; 128 128 129 129 $requested_fields = array(); 130 130 foreach ( $fields as $field => $include ) { 131 131 if ( is_int( $field ) ) { 132 $field = $include;132 $field = $include; 133 133 $include = true; 134 134 if ( '-' == substr( $field, 0, 1 ) ) { 135 135 $include = false; 136 $field = substr( $field, 1 );136 $field = substr( $field, 1 ); 137 137 } 138 138 } … … 151 151 $query = array(); 152 152 // Paging 153 $query['paged'] = isset( $this->args->page ) ? $this->args->page: 1;153 $query['paged'] = isset( $this->args->page ) ? $this->args->page : 1; 154 154 $query['posts_per_page'] = isset( $this->args->per_page ) ? $this->args->per_page : 24; 155 155 … … 157 157 if ( ! empty( $this->args->browse ) ) { 158 158 $query['browse'] = $this->args->browse; 159 if ( ! empty( $this->args->installed_plugins ) )159 if ( ! empty( $this->args->installed_plugins ) ) { 160 160 $query['installed_plugins'] = is_array( $this->args->installed_plugins ) ? $this->args->installed_plugins : array(); 161 161 } 162 162 } elseif ( ! empty( $this->args->user ) ) { 163 $query['browse'] = 'favorites';163 $query['browse'] = 'favorites'; 164 164 $query['favorites_user'] = $this->args->user; 165 165 … … 180 180 $query['author_name'] = $this->args->author; 181 181 } 182 183 182 } 184 183
Note: See TracChangeset
for help on using the changeset viewer.