summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/shortcodes')
-rw-r--r--plugins/jetpack/modules/shortcodes/cartodb.php21
-rw-r--r--plugins/jetpack/modules/shortcodes/dailymotion.php114
-rw-r--r--plugins/jetpack/modules/shortcodes/slideshow.php2
-rw-r--r--plugins/jetpack/modules/shortcodes/soundcloud.php2
-rw-r--r--plugins/jetpack/modules/shortcodes/vimeo.php8
-rw-r--r--plugins/jetpack/modules/shortcodes/wufoo.php2
-rw-r--r--plugins/jetpack/modules/shortcodes/youtube.php23
7 files changed, 127 insertions, 45 deletions
diff --git a/plugins/jetpack/modules/shortcodes/cartodb.php b/plugins/jetpack/modules/shortcodes/cartodb.php
index 74292830..6f9e4f5e 100644
--- a/plugins/jetpack/modules/shortcodes/cartodb.php
+++ b/plugins/jetpack/modules/shortcodes/cartodb.php
@@ -2,17 +2,20 @@
/*
- * CartoDB
+ * Carto (formerly CartoDB)
*
- * example URL: http://osm2.cartodb.com/viz/08aef918-94da-11e4-ad83-0e0c41326911/public_map
+ * example URL: http://osm2.carto.com/viz/08aef918-94da-11e4-ad83-0e0c41326911/public_map
*
* possible patterns:
- * [username].cartodb.com/viz/[map-id]/public_map
- * [username].cartodb.com/viz/[map-id]/embed_map
- * [username].cartodb.com/viz/[map-id]/map
- * [organization].cartodb.com/u/[username]/viz/[map-id]/public_map
- * [organization].cartodb.com/u/[username]/viz/[map-id]/embed_map
- * [organization].cartodb.com/u/[username]/viz/[map-id]/map
+ * [username].carto.com/viz/[map-id]/public_map
+ * [username].carto.com/viz/[map-id]/embed_map
+ * [username].carto.com/viz/[map-id]/map
+ * [organization].carto.com/u/[username]/viz/[map-id]/public_map
+ * [organization].carto.com/u/[username]/viz/[map-id]/embed_map
+ * [organization].carto.com/u/[username]/viz/[map-id]/map
+ *
+ * On July 8th, 2016 CartoDB changed its primary domain from cartodb.com to carto.com
+ * So this shortcode still supports the cartodb.com domain for oembeds.
*/
-wp_oembed_add_provider( '#https?://(?:www\.)?[^/^\.]+\.cartodb\.com/\S+#i', 'https://services.cartodb.com/oembed', true ); \ No newline at end of file
+wp_oembed_add_provider( '#https?://(?:www\.)?[^/^\.]+\.carto(db)?\.com/\S+#i', 'https://services.carto.com/oembed', true ); \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/dailymotion.php b/plugins/jetpack/modules/shortcodes/dailymotion.php
index bd4612ec..9a904dc7 100644
--- a/plugins/jetpack/modules/shortcodes/dailymotion.php
+++ b/plugins/jetpack/modules/shortcodes/dailymotion.php
@@ -75,6 +75,11 @@ add_filter( 'pre_kses', 'dailymotion_embed_to_shortcode' );
*
* The new style is now:
* [dailymotion id=x8oma9 title=2 user=3 video=4]
+ *
+ * Supported parameters for player customization: width, height,
+ * autoplay, endscreen-enable, mute, sharing-enabled, start, subtitles-default,
+ * ui-highlight, ui-logo, ui-start-screen-info, ui-theme
+ * see https://developer.dailymotion.com/player#player-parameters
* @todo: Update code to sniff for iframe embeds and convert those to shortcodes.
*
* @param array $atts
@@ -93,40 +98,115 @@ function dailymotion_shortcode( $atts ) {
$params = shortcode_new_to_old_params( $atts );
parse_str( $params, $atts_new );
- foreach( $atts_new as $k => $v ) {
+ foreach ( $atts_new as $k => $v ) {
$atts[ $k ] = $v;
}
}
- if ( isset( $atts['id'] ) ) {
- $id = $atts['id'];
+ $atts = shortcode_atts(
+ array(
+ 'id' => '', // string
+ 'width' => '', // int
+ 'height' => '', // int
+ 'title' => '', // string
+ 'user' => '', // string
+ 'video' => '', // string
+ 'autoplay' => 0, // int
+ 'endscreen-enable' => 1, // int
+ 'mute' => 0, // int
+ 'sharing-enable' => 1, // int
+ 'start' => '', // int
+ 'subtitles-default' => '', // string
+ 'ui-highlight' => '', // string
+ 'ui-logo' => 1, // int
+ 'ui-start-screen-info' => 0, // int
+ 'ui-theme' => '', // string
+ ), $atts, 'dailymotion'
+ );
+
+ if ( isset( $atts['id'] ) && ! empty( $atts['id'] ) ) {
+ $id = urlencode( $atts['id'] );
} else {
return '<!--Dailymotion error: bad or missing ID-->';
}
- if ( ! empty( $content_width ) ) {
- $width = min( 425, intval( $content_width ) );
- } else {
- $width = 425;
+ /*set width and height using provided parameters if any */
+ $width = isset( $atts['width'] ) ? intval( $atts['width'] ) : 0 ;
+ $height = isset( $atts['height'] ) ? intval( $atts['height'] ) : 0 ;
+
+ if ( ! $width && ! $height ) {
+ if ( ! empty( $content_width ) ) {
+ $width = absint( $content_width );
+ } else {
+ $width = 425;
+ }
+ $height = $width / 425 * 334;
+ } elseif ( ! $height ) {
+ $height = $width / 425 * 334;
+ } elseif ( ! $width ) {
+ $width = $height / 334 * 425;
+ }
+
+ /**
+ * Let's add parameters if needed.
+ *
+ * @see https://developer.dailymotion.com/player
+ */
+ $player_params = array();
+
+ if ( isset( $atts['autoplay'] ) && '1' === $atts['autoplay'] ) {
+ $player_params['autoplay'] = '1';
+ }
+ if ( isset( $atts['endscreen-enable'] ) && '0' === $atts['endscreen-enable'] ) {
+ $player_params['endscreen-enable'] = '0';
+ }
+ if ( isset( $atts['mute'] ) && '1' === $atts['mute'] ) {
+ $player_params['mute'] = '1';
}
+ if ( isset( $atts['sharing-enable'] ) && '0' === $atts['sharing-enable'] ) {
+ $player_params['sharing-enable'] = '0';
+ }
+ if ( isset( $atts['start'] ) && ! empty( $atts['start'] ) ) {
+ $player_params['start'] = abs( intval( $atts['start'] ) );
+ }
+ if ( isset( $atts['subtitles-default'] ) && ! empty( $atts['subtitles-default'] ) ) {
+ $player_params['subtitles-default'] = esc_attr( $atts['subtitles-default'] );
+ }
+ if ( isset( $atts['ui-highlight'] ) && ! empty( $atts['ui-highlight'] ) ) {
+ $player_params['ui-highlight'] = esc_attr( $atts['ui-highlight'] );
+ }
+ if ( isset( $atts['ui-logo'] ) && '0' === $atts['ui-logo'] ) {
+ $player_params['ui-logo'] = '0';
+ }
+ if ( isset( $atts['ui-start-screen-info'] ) && '0' === $atts['ui-start-screen-info'] ) {
+ $player_params['ui-start-screen-info'] = '0';
+ }
+ if ( isset( $atts['ui-theme'] ) && in_array( strtolower( $atts['ui-theme'] ), array( 'dark', 'light' ) ) ) {
+ $player_params['ui-theme'] = esc_attr( $atts['ui-theme'] );
+ }
+
+ // Add those parameters to the Video URL.
+ $video_url = add_query_arg(
+ $player_params,
+ 'https://www.dailymotion.com/embed/video/' . $id
+ );
- $height = ( 425 == $width ) ? 334 : ( $width / 425 ) * 334;
- $id = urlencode( $id );
+ $output = '';
if ( preg_match( '/^[A-Za-z0-9]+$/', $id ) ) {
- $output = '<iframe width="' . $width . '" height="' . $height . '" src="' . esc_url( '//www.dailymotion.com/embed/video/' . $id ) . '" frameborder="0"></iframe>';
- $after = '';
+ $output .= '<iframe width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" src="' . esc_url( $video_url ) . '" style="border:0;" allowfullscreen></iframe>';
if ( array_key_exists( 'video', $atts ) && $video = preg_replace( '/[^-a-z0-9_]/i', '', $atts['video'] ) && array_key_exists( 'title', $atts ) && $title = wp_kses( $atts['title'], array() ) ) {
- $after .= '<br /><strong><a href="' . esc_url( 'http://www.dailymotion.com/video/' . $video ) . '" target="_blank">' . esc_html( $title ) . '</a></strong>';
+ $output .= '<br /><strong><a href="' . esc_url( 'http://www.dailymotion.com/video/' . $video ) . '" target="_blank">' . esc_html( $title ) . '</a></strong>';
}
if ( array_key_exists( 'user', $atts ) && $user = preg_replace( '/[^-a-z0-9_]/i', '', $atts['user'] ) ) {
- $after .= '<br /><em>Uploaded by <a href="' . esc_url( 'http://www.dailymotion.com/' . $user ) . '" target="_blank">' . esc_html( $user ) . '</a></em>';
+ /* translators: %s is a Dailymotion user name */
+ $output .= '<br /><em>' . wp_kses( sprintf( __( 'Uploaded by %s', 'jetpack' ), '<a href="' . esc_url( 'http://www.dailymotion.com/' . $user ) . '" target="_blank">' . esc_html( $user ) . '</a>' ), array( 'a' => array( 'href' => true, 'target' => true ) ) ) . '</em>';
}
}
- return $output . $after;
+ return $output;
}
add_shortcode( 'dailymotion', 'dailymotion_shortcode' );
@@ -143,13 +223,13 @@ function dailymotion_channel_shortcode( $atts ) {
switch( $atts['type'] ) {
case 'grid':
- return '<iframe width="300px" height="264px" scrolling="no" frameborder="0" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username . '?type=grid' ) . '"></iframe>';
+ return '<iframe width="300px" height="264px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username . '?type=grid' ) . '"></iframe>';
break;
case 'carousel':
- return '<iframe width="300px" height="360px" scrolling="no" frameborder="0" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username . '?type=carousel' ) . '"></iframe>';
+ return '<iframe width="300px" height="360px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username . '?type=carousel' ) . '"></iframe>';
break;
default:
- return '<iframe width="300px" height="78px" scrolling="no" frameborder="0" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username ) . '"></iframe>';
+ return '<iframe width="300px" height="78px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username ) . '"></iframe>';
}
}
diff --git a/plugins/jetpack/modules/shortcodes/slideshow.php b/plugins/jetpack/modules/shortcodes/slideshow.php
index 0ff568d3..949af189 100644
--- a/plugins/jetpack/modules/shortcodes/slideshow.php
+++ b/plugins/jetpack/modules/shortcodes/slideshow.php
@@ -122,7 +122,7 @@ class Jetpack_Slideshow_Shortcode {
'trans' => 'fade',
'order' => 'ASC',
'orderby' => 'menu_order ID',
- 'id' => $post->ID,
+ 'id' => isset( $post->ID ) ? $post->ID : null,
'include' => '',
'exclude' => '',
'autostart' => true,
diff --git a/plugins/jetpack/modules/shortcodes/soundcloud.php b/plugins/jetpack/modules/shortcodes/soundcloud.php
index 3295bf01..6e0b2cb1 100644
--- a/plugins/jetpack/modules/shortcodes/soundcloud.php
+++ b/plugins/jetpack/modules/shortcodes/soundcloud.php
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: SoundCloud Shortcode
-Plugin URI: http://wordpress.org/extend/plugins/soundcloud-shortcode/
+Plugin URI: https://wordpress.org/extend/plugins/soundcloud-shortcode/
Description: Converts SoundCloud WordPress shortcodes to a SoundCloud widget. Example: [soundcloud]http://soundcloud.com/forss/flickermood[/soundcloud]
Version: 2.3
Author: SoundCloud Inc., simplified for Jetpack by Automattic, Inc.
diff --git a/plugins/jetpack/modules/shortcodes/vimeo.php b/plugins/jetpack/modules/shortcodes/vimeo.php
index 3d585a0a..0a99d5fc 100644
--- a/plugins/jetpack/modules/shortcodes/vimeo.php
+++ b/plugins/jetpack/modules/shortcodes/vimeo.php
@@ -293,10 +293,8 @@ function vimeo_link_callback( $matches ) {
}
/** This filter is documented in modules/shortcodes/youtube.php */
-if ( apply_filters( 'jetpack_comments_allow_oembed', get_option('embed_autourls') ) ) {
+if ( ! is_admin() && apply_filters( 'jetpack_comments_allow_oembed', true ) ) {
// We attach wp_kses_post to comment_text in default-filters.php with priority of 10 anyway, so the iframe gets filtered out.
- if ( ! is_admin() ) {
- // Higher priority because we need it before auto-link and autop get to it
- add_filter( 'comment_text', 'vimeo_link', 1 );
- }
+ // Higher priority because we need it before auto-link and autop get to it
+ add_filter( 'comment_text', 'vimeo_link', 1 );
}
diff --git a/plugins/jetpack/modules/shortcodes/wufoo.php b/plugins/jetpack/modules/shortcodes/wufoo.php
index 3dd88a0e..6638f70f 100644
--- a/plugins/jetpack/modules/shortcodes/wufoo.php
+++ b/plugins/jetpack/modules/shortcodes/wufoo.php
@@ -4,7 +4,7 @@ Plugin Name: Wufoo Shortcode Plugin
Description: Enables shortcode to embed Wufoo forms. Usage: [wufoo username="chriscoyier" formhash="x7w3w3" autoresize="true" height="458" header="show" ssl="true"]
Author: Chris Coyier / Wufoo, evansolomon
-Based on http://wordpress.org/extend/plugins/wufoo-shortcode/
+Based on https://wordpress.org/extend/plugins/wufoo-shortcode/
http://wufoo.com/docs/code-manager/wordpress-shortcode-plugin/
*/
diff --git a/plugins/jetpack/modules/shortcodes/youtube.php b/plugins/jetpack/modules/shortcodes/youtube.php
index d5db874d..d227fa14 100644
--- a/plugins/jetpack/modules/shortcodes/youtube.php
+++ b/plugins/jetpack/modules/shortcodes/youtube.php
@@ -177,14 +177,17 @@ function youtube_id( $url ) {
$input_w = ( isset( $qargs['w'] ) && intval( $qargs['w'] ) ) ? intval( $qargs['w'] ) : 0;
$input_h = ( isset( $qargs['h'] ) && intval( $qargs['h'] ) ) ? intval( $qargs['h'] ) : 0;
- $default_width = get_option('embed_size_w');
+ // If we have $content_width, use it.
+ if ( ! empty( $content_width ) ) {
+ $default_width = $content_width;
+ } else {
+ // Otherwise get default width from the old, now deprecated embed_size_w option.
+ $default_width = get_option('embed_size_w');
+ }
+ // If we don't know those 2 values use a hardcoded width.h
if ( empty( $default_width ) ) {
- if ( ! empty( $content_width ) ) {
- $default_width = $content_width;
- } else {
- $default_width = 640;
- }
+ $default_width = 640;
}
if ( $input_w > 0 && $input_h > 0 ) {
@@ -363,12 +366,10 @@ add_action( 'init', 'wpcom_youtube_embed_crazy_url_init' );
*
* @param int get_option('embed_autourls') Option to automatically embed all plain text URLs.
*/
-if ( apply_filters( 'jetpack_comments_allow_oembed', get_option('embed_autourls') ) ) {
+if ( ! is_admin() && apply_filters( 'jetpack_comments_allow_oembed', true ) ) {
// We attach wp_kses_post to comment_text in default-filters.php with priority of 10 anyway, so the iframe gets filtered out.
- if ( ! is_admin() ) {
- // Higher priority because we need it before auto-link and autop get to it
- add_filter( 'comment_text', 'youtube_link', 1 );
- }
+ // Higher priority because we need it before auto-link and autop get to it
+ add_filter( 'comment_text', 'youtube_link', 1 );
}
/**