Changeset 13071
- Timestamp:
- 12/19/2023 07:07:11 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-serve.php
r8484 r13071 17 17 try { 18 18 $request = $this->determine_request(); 19 20 $this->maybe_redirect_latest_stable( $request ); 19 21 20 22 $this->serve_zip( $request ); … … 56 58 $version = $m['version']; 57 59 } 58 if ( 'latest-stable' == $version ) { 60 61 // If the latest-stable is requested, determine the file to serve. 62 $is_latest_stable = ( 'latest-stable' == $version ); 63 if ( $is_latest_stable ) { 59 64 $version = $this->get_stable_tag( $slug ); 60 65 } … … 79 84 } 80 85 81 return compact( 'zip', 'slug', 'version', 'args', 'checksum_request', 'signature_request' ); 86 87 return compact( 'zip', 'slug', 'version', 'args', 'checksum_request', 'signature_request', 'is_latest_stable' ); 88 } 89 90 /** 91 * Redirect to the latest stable version if requested. 92 * 93 * @param array $request The request array for the request. 94 */ 95 protected function maybe_redirect_latest_stable( $request ) { 96 if ( ! $request['is_latest_stable'] ) { 97 return; 98 } 99 100 $file = $this->get_file( $request ); 101 $redirect = 'https://downloads.wordpress.org/plugin/' . basename( $file ); 102 103 if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { 104 $redirect .= '?' . $_SERVER['QUERY_STRING']; 105 } 106 107 // CORS, to match the ZIP passthrough. 108 header( 'Access-Control-Allow-Methods: GET, HEAD' ); 109 header( 'Access-Control-Allow-Origin: *' ); 110 111 // Tell browsers to only cache this for 5 minutes. 112 header( 'Cache-Control: max-age=300' ); 113 114 // Redirect to the file they want. 115 header( 'Location: ' . $redirect, 302 ); 116 exit; 82 117 } 83 118
Note: See TracChangeset
for help on using the changeset viewer.