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