Changeset 12302
- Timestamp:
- 12/07/2022 06:43:57 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-blocks.php
r12301 r12302 33 33 // Allow the oEmbed proxy endpoint for any user who can publish a thread/reply.. 34 34 add_filter( 'rest_api_init', [ $this, 'overwrite_oembed_10_proxy_permission' ], 20 ); 35 36 // Hack to make Imgur embeds work. This should be fixed by Imgur. 37 add_filter( 'oembed_remote_get_args', [ $this, 'oembed_remote_get_args' ], 10, 2 ); 35 38 } 36 39 … … 82 85 ]; 83 86 84 // TODO: To modify the available embeds modify $settings['iso']['allowEmbeds'] 87 $settings['iso']['allowEmbeds'] = array_diff( 88 $settings['iso']['allowEmbeds'], 89 [ 90 // Disable screencast, it seems not to work. 91 'screencast', 92 ] 93 ); 85 94 86 95 return $settings; … … 109 118 ); 110 119 } 120 121 /** 122 * Imgur oEmbed API appears to block any request with a lowercase 'wordpress' in the user-agent. 123 * 124 * @param array $http_args The args to pass to wp_safe_remote_get(). 125 * @param string $provider_url The URL of the oEmbed provider to be requested. 126 * @return array The modified $http_args. 127 */ 128 public function oembed_remote_get_args( $http_args, $provider_url ) { 129 if ( str_contains( $provider_url, 'imgur.com' ) ) { 130 $http_args['user-agent'] = apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), $provider_url ); 131 $http_args['user-agent'] = str_replace( 'wordpress', 'WordPress', $http_args['user-agent'] ); 132 } 133 134 return $http_args; 135 } 111 136 }
Note: See TracChangeset
for help on using the changeset viewer.