Skip to content
Commits on Source (5)
......@@ -3,14 +3,14 @@
* Plugin Name: A/I - Add oembed provider and embed short
* Plugin URI:
* Description: Add oEmbed providers
* Version: 1.3.0
* Version: 1.3.1
* Author: Autistici/Inventati
* Author URI: https://autistici.org
**/
function wp_embed_handler_google_maps( $matches, $attr, $url, $rawattr ) {
$width = ($rawattr['width']) ? $rawattr['width'] : 425 ;
$height = ($rawattr['height']) ? $rawattr['height'] : 350 ;
$width = $rawattr['width'] ?? 425 ;
$height = $rawattr['height'] ?? 350 ;
$query = add_query_arg(array('output' => 'embed'), $matches[0]);
$embed = '<iframe width="'.esc_attr($width).'" height="'.esc_attr($height).'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.esc_attr($query).'"></iframe>';
......@@ -18,8 +18,8 @@ function wp_embed_handler_google_maps( $matches, $attr, $url, $rawattr ) {
}
function wp_embed_handler_openstreetmap( $matches, $attr, $url, $rawattr ) {
$width = ($rawattr['width']) ? $rawattr['width'] : 425 ;
$height = ($rawattr['height']) ? $rawattr['height'] : 350 ;
$width = $rawattr['width'] ?? 425 ;
$height = $rawattr['height'] ?? 350 ;
$embed = '<iframe width="'.esc_attr($width).'" height="'.esc_attr($height).'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.esc_attr($matches[0]).'"></iframe>';
return apply_filters( 'embed_openstreetmap', $embed, $matches, $attr, $url, $rawattr );
......@@ -59,10 +59,10 @@ function wp_embed_handler_archive( $matches, $attr, $url, $rawattr ) {
}
function wp_embed_handler_dctptv( $matches, $attr, $url, $rawattr ) {
$width = ($attr['width']) ? $attr['width'] : 480 ;
$height = ($attr['height']) ? $attr['height'] : 396 ;
$width = $attr['width'] ?? 480 ;
$height = $attr['height'] ?? 396 ;
$embed= sprintf(
'<iframe width="%3$s" scrolling="no" height="%2$s" frameborder="0" src="%1$s" name="dctp-teaser" marginwidth="0" marginheight="0"><br>
'<iframe width="%3$s" scrolling="no" height="%2$s" frameborder="0" src="%1$s" name="dctp-embed" marginwidth="0" marginheight="0"><br>
</iframe>',esc_attr($matches[0]),esc_attr($height),esc_attr($width));
return apply_filters( 'embed_dctptv', $embed, $matches, $attr, $url, $rawattr );
......@@ -73,10 +73,10 @@ function register_embed_handlers() {
add_shortcode('archiveorg', 'shortcode_archiveorg');
wp_embed_register_handler( 'archive', '#http[s]?://(?:www\.)?archive\.org/.*/(?<id>.*)#i', 'wp_embed_handler_archive' );
wp_embed_register_handler( 'dctptv', '#http(s)?://www.dctp\.tv/embed/.*?/#i', 'wp_embed_handler_dctptv' );
wp_embed_register_handler( 'dctptv', '#http(s)?://www.dctp\.tv/.*#i', 'wp_embed_handler_dctptv' );
wp_embed_register_handler( 'googlemaps', '#http(s)?://maps\.google\.[^\.]+/(.*)#i', 'wp_embed_handler_google_maps');
wp_embed_register_handler( 'openstreetmap', '#http(s)?://www\.openstreetmap\.org/export/embed.html\?(.*)#i', 'wp_embed_handler_openstreetmap');
wp_embed_register_handler( 'googlemaps', '#http[s]?://www\.google\.[^\.]+/maps/embed.*#i', 'wp_embed_handler_google_maps');
wp_embed_register_handler( 'openstreetmap', '#http[s]?://www\.openstreetmap\.org/export/embed.html\?.*#i', 'wp_embed_handler_openstreetmap');
}
add_action('wp', 'register_embed_handlers');
......@@ -86,7 +86,7 @@ $noembed_site = array(
"https?://www\\.urbandictionary\\.com/define\\.php\\?term=.+",
"https?://(?:www\\.)?xkcd\\.com/\\d+/?",
"https?://.*\\.deviantart\\.com/art/.*",
"https?://.*\\.deviantart\\.com/.*#/d.*",
"https?://.*\\.deviantart\\.com/.*\#/d.*",
"https?://instagram\\.com/p/.*",
"https?://instagr\\.am/p/.*",
"https?://instagram\\.com/p/.*",
......