Changeset 13610 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
- Timestamp:
- 04/29/2024 07:36:53 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r13438 r13610 52 52 add_action( 'wp_head', array( Template::class, 'hreflang_link_attributes' ), 2 ); 53 53 add_filter( 'allowed_redirect_hosts', array( $this, 'filter_redirect_hosts' ) ); 54 add_filter( 'wp_get_attachment_url', array( $this, 'add_info_to_zip_url' ), 100, 2 ); 54 55 55 56 // Add no-index headers where appropriate. … … 1832 1833 1833 1834 return update_post_meta( $plugin->ID, 'releases', $releases ); 1835 } 1836 1837 /** 1838 * Add additional context to ZIP urls. 1839 * 1840 * The ZIP URL will have a 'info' key attached which is a rest api URL to information about the plugin. 1841 * 1842 * @param string $url The URL to the ZIP file. 1843 * @param int $attachment_id The attachment ID. 1844 * @return string The URL to the ZIP file. 1845 */ 1846 public function add_info_to_zip_url( $url, $attachment_id ) { 1847 $attachment = get_post( $attachment_id ); 1848 $post = get_post( $attachment->post_parent ); 1849 $token = $post->{'_pending_access_token'} ?? false; 1850 1851 if ( ! $url || ! $attachment || ! $post || ! $token || ! current_user_can( 'edit_post', $post->ID ) ) { 1852 return $url; 1853 } 1854 1855 $url = add_query_arg( 1856 'info', 1857 urlencode( rest_url( sprintf( 1858 'plugins/v1/pending-plugin/%d-%s/', 1859 $post->ID, 1860 $token 1861 ) ) ), 1862 $url 1863 ); 1864 1865 return $url; 1834 1866 } 1835 1867
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)