';
}
global $wp_embed;
return $wp_embed->shortcode( $atts, $url );
}
/**
* Converts Kickstarter iframe embeds to a shortcode.
*
* EG:
*
* @since 4.5.0
*
* @param string $content Entry content that possibly includes a Kickstarter embed.
*
* @return string
*/
function jetpack_kickstarter_embed_to_shortcode( $content ) {
if ( ! is_string( $content ) || false === stripos( $content, 'www.kickstarter.com/projects' ) ) {
return $content;
}
$regexp = '!!i';
$regexp_ent = str_replace( '�*58;', '�*58;|*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) ); // phpcs:ignore
foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) {
if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) {
continue;
}
foreach ( $matches as $match ) {
$url = esc_url( $match[2] );
$params = $match[1] . $match[3];
if ( 'regexp_ent' === $reg ) {
$params = html_entity_decode( $params );
}
$params = wp_kses_hair( $params, array( 'http' ) );
$width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0;
$shortcode = '[kickstarter url=' . $url . ( ( ! empty( $width ) ) ? " width=$width" : '' ) . ']';
$content = str_replace( $match[0], $shortcode, $content );
}
}
return $content;
}