- Timestamp:
- 02/24/2022 06:19:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/dotorg/trac/oembed/index.php
r11598 r11599 33 33 // meta|core are the only tracs embedable. 34 34 // milestone|ticketgraph|ticket|changeset are the only endpoints allowable. 35 ! preg_match( '!^(?P<baseurl>https://(?P<trac>meta|core).trac.wordpress.org/)(?P<type>milestone|ticketgraph|ticket|changeset )([/?]|$)!i', $url, $m ) ||35 ! preg_match( '!^(?P<baseurl>https://(?P<trac>meta|core).trac.wordpress.org/)(?P<type>milestone|ticketgraph|ticket|changeset|query)([/?]|$)!i', $url, $m ) || 36 36 'GET' !== $_SERVER['REQUEST_METHOD'] 37 37 ) { … … 170 170 } 171 171 break; 172 case 'query': 173 $remove_tags[] = 'h1'; 174 $remove_tags[] = 'h2'; 175 break; 172 176 } 173 177 … … 187 191 } 188 192 193 $elements_to_remove = []; 189 194 foreach ( $doc->getElementsByTagName( $tag ) as $el ) { 190 195 if ( $class && ! str_contains( $el->getAttribute( 'class' ), $class ) ) { … … 192 197 } 193 198 199 $elements_to_remove[] = $el; 200 } 201 202 foreach ( $elements_to_remove as $el ) { 194 203 $el->parentNode->removeChild( $el ); 195 204 } … … 227 236 228 237 // Remove wp-trac.js, we don't need it here - It alters the page too much and adds elements on load. 229 // Recursive as it can't iterate over the document while altering it properly. 230 do { 231 $removed = 0; 232 foreach ( $doc->getElementsByTagName( 'script' ) as $script ) { 233 $src = (string) $script->getAttribute( 'src' ); 234 235 if ( 236 false !== stripos( $src, 'wp-trac.js' ) || 237 false !== stripos( $script->textContent, 'wpTrac' ) 238 ) { 239 $script->parentNode->removeChild( $script ); 240 $removed++; 241 } 242 } 243 } while ( $removed ); 238 $elements_to_remove = []; 239 foreach ( $doc->getElementsByTagName( 'script' ) as $script ) { 240 $src = (string) $script->getAttribute( 'src' ); 241 242 if ( 243 false !== stripos( $src, 'wp-trac.js' ) || 244 false !== stripos( $script->textContent, 'wpTrac' ) 245 ) { 246 $elements_to_remove[] = $script; 247 } 248 } 249 foreach ( $elements_to_remove as $el ) { 250 $el->parentNode->removeChild( $el ); 251 } 244 252 245 253 // Add a script to the header.
Note: See TracChangeset
for help on using the changeset viewer.