You appear to be a bot. Output may be restricted
Description
Compose shortcode from archive.org iframe.
Usage
$mixed = jetpack_archiveorg_embed_to_shortcode( $content );
Parameters
- $content
- ( string ) required – Post content.
Returns
mixed
Source
File name: jetpack/modules/shortcodes/archiveorg.php
Lines:
1 to 48 of 48
function jetpack_archiveorg_embed_to_shortcode( $content ) { if ( ! is_string( $content ) || false === stripos( $content, 'archive.org/embed/' ) ) { return $content; } $regexp = '!<iframe\s+src=[\'"]https?://archive\.org/embed/([^\'"]+)[\'"]((?:\s+\w+(=[\'"][^\'"]*[\'"])?)*)></iframe>!i'; if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) { return $content; } foreach ( $matches as $match ) { $url = explode( '&', $match[1] ); $id = 'id=' . $url[0]; $autoplay = ''; $poster = ''; $url_count = count( $url ); for ( $ii = 1; $ii < $url_count; $ii++ ) { if ( 'autoplay=1' === $url[ $ii ] ) { $autoplay = ' autoplay="1"'; } $map_matches = array(); if ( preg_match( '/^poster=(.+)$/', $url[ $ii ], $map_matches ) ) { $poster = " poster=\"{$map_matches[1]}\""; } } $params = $match[2]; $params = wp_kses_hair( $params, array( 'http' ) ); $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0; $height = isset( $params['height'] ) ? (int) $params['height']['value'] : 0; $wh = ''; if ( $width && $height ) { $wh = ' width=' . $width . ' height=' . $height; } $shortcode = '[archiveorg ' . $id . $wh . $autoplay . $poster . ']'; $content = str_replace( $match[0], $shortcode, $content ); } return $content; }