Changeset 11586
- Timestamp:
- 02/21/2022 06:34:52 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/dotorg/trac/oembed/index.php
r11412 r11586 46 46 $id = sha1( $url . microtime() ); 47 47 48 $embed = [ 49 'version' => '1.0', 50 'provider_name' => 'WordPress.org Trac', 51 'provider_url' => $m['baseurl'], 52 'title' => 'WordPress.org Trac', 53 'type' => 'rich', 54 'width' => 600, 55 'height' => 300, 56 'html' => '', 57 ]; 58 59 // Default milestone embeds to 120px height. 60 if ( 'milestone' === $type ) { 61 $embed['height'] = 120; 62 } 63 48 64 $embed_url = add_query_arg( 49 65 [ … … 61 77 62 78 $html = sprintf( 63 '<iframe sandbox="allow-scripts allow-top-navigation-by-user-activation" security="restricted" src="%s" id="%s" width=" 600" height="300" title="WordPress.org Trac" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content wporg-trac"></iframe>',79 '<iframe sandbox="allow-scripts allow-top-navigation-by-user-activation" security="restricted" src="%s" id="%s" width="%d" height="%d" title="WordPress.org Trac" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content wporg-trac"></iframe>', 64 80 esc_url( $embed_url ), 65 esc_attr( 'el-' . $id ) 81 esc_attr( 'el-' . $id ), 82 esc_attr( $embed['width'] ), 83 esc_attr( $embed['height'] ) 66 84 ); 67 85 … … 84 102 ); 85 103 86 $embed = [ 87 'version' => '1.0', 88 'provider_name' => 'WordPress.org Trac', 89 'provider_url' => $m['baseurl'], 90 'title' => 'WordPress.org Trac', 91 'type' => 'rich', 92 'width' => 600, 93 'height' => 300, 94 'html' => $html, 95 ]; 96 97 // Default milestone embeds to 120px. 98 if ( 'milestone' === $type ) { 99 $embed['height'] = 120; 100 } 104 $embed['html'] = $html; 101 105 102 106 echo wp_json_encode( $embed ); … … 131 135 // IDs of elements to remove 132 136 $remove_elements = [ 133 'wporg-header', 'wporg-footer',134 137 'headline', 'banner', 'mainnav', 135 138 'ctxtnav', 'help', 'altlinks', 136 139 'prefs', 140 'wporg-global-header-script-js', 141 'wporg-global-header-script-js-extra', 142 'wporg-global-header-footer-css', 137 143 ]; 138 144 139 // Tags to just strip out.145 // Tags, with optional class specification to just strip out. 140 146 $remove_tags = [ 141 'form' 147 'form', 148 'header.global-header', 149 'footer.global-footer', 142 150 ]; 143 151 … … 171 179 // Remove any tags 172 180 foreach ( $remove_tags as $tag ) { 181 list( $tag, $class ) = explode( '.', $tag, 2 ); 173 182 foreach ( $doc->getElementsByTagName( $tag ) as $el ) { 183 if ( $class && ! str_contains( $el->getAttribute( 'class' ), $class ) ) { 184 continue; 185 } 186 174 187 $el->parentNode->removeChild( $el ); 175 188 } … … 243 256 $doc->getElementsByTagName( 'head' )[0]->appendChild( $doc->createElement( 'script', $js ) ); 244 257 258 $css = <<<CSS 259 html { 260 --wp-global-header-height: 0; 261 --wp-admin--admin-bar--height: 0; 262 } 263 CSS; 264 $doc->getElementsByTagName( 'head' )[0]->appendChild( $doc->createElement( 'style', $css ) ); 265 245 266 $data = $doc->saveHTML(); 246 267
Note: See TracChangeset
for help on using the changeset viewer.