Ejemplo n.º 1
0
function slideshare_shortcode($atts)
{
    global $content_width;
    $params = shortcode_new_to_old_params($atts);
    parse_str($params, $arguments);
    if (empty($arguments)) {
        return "<!-- SlideShare error: no arguments -->";
    }
    extract($arguments);
    $pattern = '/[^-_a-zA-Z0-9]/';
    if (empty($id) || preg_match($pattern, $id)) {
        return "<!-- SlideShare error: id is missing or has illegal characters -->";
    }
    if (empty($doc) || preg_match($pattern, $doc)) {
        return "<!-- SlideShare error: doc is missing or has illegal characters -->";
    }
    if (empty($w) && !empty($content_width)) {
        $w = intval($content_width);
    } elseif (!($w = intval($w)) || $w < 300 || $w > 1600) {
        $w = 425;
    } else {
        $w = intval($w);
    }
    $h = ceil($w * 348 / 425);
    $player = "<object type='application/x-shockwave-flash' wmode='opaque' data='http://static.slideshare.net/swf/ssplayer2.swf?id={$id}&doc={$doc}' width='{$w}' height='{$h}'><param name='movie' value='http://static.slideshare.net/swf/ssplayer2.swf?id={$id}&doc={$doc}' /><param name='allowFullScreen' value='true' /></object>";
    if (!empty($type) && $type == 'd') {
        $player = "<object style='margin: 0px;' width='{$w}' height='{$h}'><param name='movie' value='http://static.slidesharecdn.com/swf/ssplayerd.swf?doc={$doc}' /><param name='allowFullScreen' value='true' /><param name='wmode' value='opaque' /><embed src='http://static.slidesharecdn.com/swf/ssplayerd.swf?doc={$doc}' type='application/x-shockwave-flash' allowfullscreen='true' wmode='opaque' width='{$w}' height='{$h}'></embed></object>";
    }
    return $player;
}
Ejemplo n.º 2
0
/**
 * DailyMotion shortcode
 *
 * The documented shortcode is:
 * [dailymotion id=x8oma9]
 *
 * Possibilities, according to the old parsing regexp:
 * [dailymotion x8oma9]
 * [dailymotion=x8oma9]
 *
 * Hypothetical option, according to the old shortcode function is
 * [dailymotion id=1&title=2&user=3&video=4]
 *
 * The new style is now:
 * [dailymotion id=x8oma9 title=2 user=3 video=4]
 * @todo: Update code to sniff for iframe embeds and convert those to shortcodes.
 *
 * @param array $atts
 * @return string html
 *
 */
function dailymotion_shortcode($atts)
{
    global $content_width;
    if (isset($atts[0])) {
        $id = ltrim($atts[0], '=');
        $atts['id'] = $id;
    } else {
        $params = shortcode_new_to_old_params($atts);
        parse_str($params, $atts);
    }
    if (isset($atts['id'])) {
        $id = $atts['id'];
    } else {
        return '<!--Dailymotion error: bad or missing ID-->';
    }
    if (!empty($content_width)) {
        $width = min(425, intval($content_width));
    } else {
        $width = 425;
    }
    $height = 425 == $width ? 334 : $width / 425 * 334;
    $id = urlencode($id);
    if (preg_match('/^[A-Za-z0-9]+$/', $id)) {
        $output = '<iframe width="' . $width . '" height="' . $height . '" src="http://www.dailymotion.com/embed/video/' . $id . '" frameborder="0"></iframe>';
        $after = '';
        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="http://www.dailymotion.com/video/' . $video . '">' . $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="http://www.dailymotion.com/' . $user . '">' . $user . '</a></em>';
        }
    }
    return $output . $after;
}
Ejemplo n.º 3
0
function slideshare_shortcode($atts)
{
    global $content_width;
    $params = shortcode_new_to_old_params($atts);
    parse_str($params, $arguments);
    if (empty($arguments)) {
        return '<!-- SlideShare error: no arguments -->';
    }
    extract($arguments);
    // check that the Slideshare ID contains letters, numbers and query strings
    $pattern = '/[^-_a-zA-Z0-9?=&]/';
    if (empty($id) || preg_match($pattern, $id)) {
        return '<!-- SlideShare error: id is missing or has illegal characters -->';
    }
    // check the width/height
    if (empty($w) && !empty($content_width)) {
        $w = intval($content_width);
    } elseif (!($w = intval($w)) || $w < 300 || $w > 1600) {
        $w = 425;
    } else {
        $w = intval($w);
    }
    $h = ceil($w * 348 / 425);
    if (isset($pro)) {
        $source = "https://www.slideshare.net/slidesharepro/{$id}";
    } else {
        $source = "https://www.slideshare.net/slideshow/embed_code/{$id}";
    }
    if (isset($rel)) {
        $source = add_query_arg('rel', intval($rel), $source);
    }
    if (isset($startSlide)) {
        $source = add_query_arg('startSlide', intval($startSlide), $source);
    }
    $player = sprintf("<iframe src='%s' width='%d' height='%d'", esc_url($source), $w, $h);
    // check the frameborder
    if (isset($fb)) {
        $player .= " frameborder='" . intval($fb) . "'";
    }
    // check the margin width; if not empty, cast as int
    if (isset($mw)) {
        $player .= " marginwidth='" . intval($mw) . "'";
    }
    // check the margin height, if not empty, cast as int
    if (isset($mh)) {
        $player .= " marginheight='" . intval($mh) . "'";
    }
    if (!empty($style)) {
        $player .= " style='" . $style . "'";
    }
    // check the scrollbar; cast as a lowercase string for comparison
    $sc = isset($sc) ? strtolower($sc) : '';
    if (in_array($sc, array('yes', 'no'))) {
        $player .= " scrolling='" . $sc . "'";
    }
    $player .= ' allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>';
    return $player;
}
Ejemplo n.º 4
0
/**
 * Convert a Vimeo shortcode into an embed code.
 *
 * @param array $atts An array of shortcode attributes.
 * @return string The embed code for the Vimeo video.
 */
function vimeo_shortcode($atts)
{
    global $content_width;
    extract(array_map('intval', shortcode_atts(array('id' => 0, 'width' => 400, 'height' => 300, 'autoplay' => 0, 'loop' => 0), $atts, 'vimeo')));
    if (isset($atts[0])) {
        $id = jetpack_shortcode_get_vimeo_id($atts);
    }
    if (!$id) {
        return "<!-- vimeo error: not a vimeo video -->";
    }
    // [vimeo 141358 h=500&w=350]
    $params = shortcode_new_to_old_params($atts);
    // h=500&w=350
    $params = str_replace(array('&amp;', '&#038;'), '&', $params);
    parse_str($params, $args);
    if (isset($args['w'])) {
        $width = (int) $args['w'];
        if (!isset($args['h'])) {
            // The case where w=300 is specified without h=200, otherwise $height
            // will always equal the default of 300, no matter what w was set to.
            $height = round($width / 640 * 360);
        }
    }
    if (isset($args['h'])) {
        $height = (int) $args['h'];
        if (!isset($args['w'])) {
            $width = round($height / 360 * 640);
        }
    }
    if (!$width) {
        $width = absint($content_width);
    }
    if (!$height) {
        $height = round($width / 640 * 360);
    }
    $url = esc_url(set_url_scheme("http://player.vimeo.com/video/{$id}"));
    // $args['autoplay'] is parsed from the embedded url.
    // $autoplay is parsed from shortcode arguments.
    // in_array( 'autoplay', $atts ) catches the argument passed without a value.
    if (!empty($args['autoplay']) || !empty($autoplay) || in_array('autoplay', $atts)) {
        $url = add_query_arg('autoplay', 1, $url);
    }
    if (!empty($args['loop']) || !empty($loop) || in_array('loop', $atts)) {
        $url = add_query_arg('loop', 1, $url);
    }
    $html = sprintf('<div class="embed-vimeo" style="text-align:center;"><iframe src="%1$s" width="%2$u" height="%3$u" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>', esc_url($url), $width, $height);
    $html = apply_filters('video_embed_html', $html);
    return $html;
}
Ejemplo n.º 5
0
 public function shortcode($attr)
 {
     $url = false;
     $video_id = false;
     if (isset($attr[0])) {
         $url = ltrim($attr[0], '=');
     } elseif (function_exists('shortcode_new_to_old_params')) {
         $url = shortcode_new_to_old_params($attr);
     }
     if (empty($url)) {
         return '';
     }
     $video_id = $this->get_video_id_from_url($url);
     return $this->render(array('url' => $url, 'video_id' => $video_id));
 }
Ejemplo n.º 6
0
function vimeo_shortcode($atts)
{
    global $content_width;
    extract(array_map('intval', shortcode_atts(array('id' => 0, 'width' => 400, 'height' => 300), $atts)));
    if (isset($atts[0])) {
        $atts[0] = trim($atts[0], '=');
        if (is_numeric($atts[0])) {
            $id = (int) $atts[0];
        } elseif (preg_match('|vimeo.com/(\\d+)/?$|i', $atts[0], $match)) {
            $id = (int) $match[1];
        }
    }
    // [vimeo 141358 h=500&w=350]
    $params = shortcode_new_to_old_params($atts);
    // h=500&w=350
    $params = str_replace(array('&amp;', '&#038;'), '&', $params);
    parse_str($params, $args);
    if (isset($args['w'])) {
        $width = (int) $args['w'];
    }
    if (isset($args['h'])) {
        $height = (int) $args['h'];
    }
    if (!$width) {
        $width = absint($content_width);
    }
    if (!$height) {
        $height = round($width / 640 * 360);
    }
    if (!$id) {
        return "<!-- vimeo error: not a vimeo video -->";
    }
    return <<<EOS
<div style='text-align:center;'>
<object type="application/x-shockwave-flash" width="{$width}" height="{$height}" data="http://www.vimeo.com/moogaloop.swf?clip_id={$id}&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=01AAEA">
\t<param name="quality" value="best" />
\t<param name="allowfullscreen" value="true" />
\t<param name="scale" value="showAll" />
\t<param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id={$id}&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=01AAEA" />
\t<param name="wmode" value="opaque" />
</object>
</div>
EOS;
}
Ejemplo n.º 7
0
/**
 * Convert a Vimeo shortcode into an embed code.
 *
 * @param array $atts An array of shortcode attributes.
 * @return string The embed code for the Vimeo video.
 */
function vimeo_shortcode($atts)
{
    global $content_width;
    extract(array_map('intval', shortcode_atts(array('id' => 0, 'width' => 400, 'height' => 300), $atts)));
    if (isset($atts[0])) {
        $atts[0] = trim($atts[0], '=');
        if (is_numeric($atts[0])) {
            $id = (int) $atts[0];
        } elseif (preg_match('|vimeo\\.com/(\\d+)/?$|i', $atts[0], $match)) {
            $id = (int) $match[1];
        }
    }
    // [vimeo 141358 h=500&w=350]
    $params = shortcode_new_to_old_params($atts);
    // h=500&w=350
    $params = str_replace(array('&amp;', '&#038;'), '&', $params);
    parse_str($params, $args);
    if (isset($args['w'])) {
        $width = (int) $args['w'];
        if (!isset($args['h'])) {
            // The case where w=300 is specified without h=200, otherwise $height
            // will always equal the default of 300, no matter what w was set to.
            $height = round($width / 640 * 360);
        }
    }
    if (isset($args['h'])) {
        $height = (int) $args['h'];
        if (!isset($args['w'])) {
            $width = round($height / 360 * 640);
        }
    }
    if (!$width) {
        $width = absint($content_width);
    }
    if (!$height) {
        $height = round($width / 640 * 360);
    }
    if (!$id) {
        return "<!-- vimeo error: not a vimeo video -->";
    }
    $html = "<div class='embed-vimeo' style='text-align:center;'><iframe src='http://player.vimeo.com/video/{$id}' width='{$width}' height='{$height}' frameborder='0'></iframe></div>";
    $html = apply_filters('video_embed_html', $html);
    return $html;
}
Ejemplo n.º 8
0
function jetpack_slide_embed($type, $atts)
{
    $param = shortcode_new_to_old_params($atts);
    if (ctype_digit($param)) {
        $id = $param;
        $w = 426;
        $h = 320;
    } else {
        parse_str($param, $params);
        if (count($params) != 3 || !isset($params['id']) || !isset($params['w']) || !isset($params['h'])) {
            return '<!-- Slide.com error: provide id, w, h -->';
        }
        extract($params);
        if (!ctype_digit($id) || !ctype_digit($w) || !ctype_digit($h)) {
            return '<!-- Slide.com error: provide integers -->';
        }
    }
    $partition = sprintf('%02x', $id % 256);
    if ('slideshow' == $type) {
        return "<div><embed src='http://widget-{$partition}.slide.com/widgets/slideticker.swf' type='application/x-shockwave-flash' quality='high' scale='noscale' salign='l' wmode='transparent' flashvars='site=widget-{$partition}.slide.com&channel={$id}&cy=wp&il=1' width='{$w}' height='{$h}' name='flashticker' align='middle' /><div style='width: {$w}px;text-align:left;'><a href='http://www.slide.com/pivot?ad=0&tt=0&sk=0&cy=wp&th=0&id={$id}&map=1' target='_blank'><img src='http://widget-{$partition}.slide.com/p1/{$id}/wp_t000_v000_a000_f00/images/xslide1.gif' border='0' ismap='ismap' /></a> <a href='http://www.slide.com/pivot?ad=0&tt=0&sk=0&cy=wp&th=0&id={$id}&map=2' target='_blank'><img src='http://widget-{$partition}.slide.com/p2/{$id}/wp_t000_v000_a000_f00/images/xslide2.gif' border='0' ismap='ismap' /></a></div></div>";
    } else {
        return "<div><embed src='http://widget-{$partition}.slide.com/widgets/slidemap.swf' type='application/x-shockwave-flash' quality='high' scale='noscale' salign='l' wmode='transparent' flashvars='site=widget-{$partition}.slide.com&channel={$id}&cy=wp&il=1' width='{$w}' height='{$h}' name='flashticker' align='middle' /><div style='width:{$w}px;text-align:left;'><a href='http://www.slide.com/pivot?ad=0&tt=0&sk=0&cy=wp&th=0&id={$id}&map=5' target='_blank'><img src='http://widget-{$partition}.slide.com/c1/{$id}/wp_t000_v000_a000_f00/images/xslide1.gif' border='0' ismap='ismap' /></a> <a href='http://www.slide.com/pivot?ad=0&tt=0&sk=0&cy=wp&th=0&id={$id}&map=6' target='_blank'><img src='http://widget-{$partition}.slide.com/c2/{$id}/wp_t000_v000_a000_f00/images/xslide6.gif' border='0' ismap='ismap' /></a></div></div>";
    }
}
Ejemplo n.º 9
0
function youtube_shortcode($atts)
{
    return youtube_id(isset($atts[0]) ? ltrim($atts[0], '=') : shortcode_new_to_old_params($atts));
}
Ejemplo n.º 10
0
function youtube_shortcode($atts)
{
    if (isset($atts[0])) {
        $src = ltrim($atts[0], '=');
    } else {
        $src = shortcode_new_to_old_params($atts);
    }
    return youtube_id($src);
}
Ejemplo n.º 11
0
/**
 * Convert a Vimeo shortcode into an embed code.
 *
 * @param array $atts An array of shortcode attributes.
 *
 * @return string The embed code for the Vimeo video.
 */
function vimeo_shortcode($atts)
{
    global $content_width;
    $attr = array_map('intval', shortcode_atts(array('id' => 0, 'width' => 0, 'height' => 0, 'autoplay' => 0, 'loop' => 0), $atts));
    if (isset($atts[0])) {
        $attr['id'] = jetpack_shortcode_get_vimeo_id($atts);
    }
    if (!$attr['id']) {
        return '<!-- vimeo error: not a vimeo video -->';
    }
    // [vimeo 141358 h=500&w=350]
    $params = shortcode_new_to_old_params($atts);
    // h=500&w=350
    $params = str_replace(array('&amp;', '&#038;'), '&', $params);
    parse_str($params, $args);
    $width = intval($attr['width']);
    $height = intval($attr['height']);
    // Support w and h argument as fallback.
    if (empty($width) && isset($args['w'])) {
        $width = intval($args['w']);
        if (empty($height) && !isset($args['h'])) {
            // The case where w=300 is specified without h=200, otherwise $height
            // will always equal the default of 300, no matter what w was set to.
            $height = round($width / 640 * 360);
        }
    }
    if (empty($height) && isset($args['h'])) {
        $height = (int) $args['h'];
        if (!isset($args['w'])) {
            $width = round($height / 360 * 640);
        }
    }
    if (!$width && !empty($content_width)) {
        $width = absint($content_width);
    }
    // If setting the width with content_width has failed, defaulting
    if (!$width) {
        $width = 640;
    }
    if (!$height) {
        $height = round($width / 640 * 360);
    }
    /**
     * Filter the Vimeo player width.
     *
     * @module shortcodes
     *
     * @since 3.4.0
     *
     * @param int $width Width of the Vimeo player in pixels.
     */
    $width = (int) apply_filters('vimeo_width', $width);
    /**
     * Filter the Vimeo player height.
     *
     * @module shortcodes
     *
     * @since 3.4.0
     *
     * @param int $height Height of the Vimeo player in pixels.
     */
    $height = (int) apply_filters('vimeo_height', $height);
    $url = esc_url('https://player.vimeo.com/video/' . $attr['id']);
    // Handle autoplay and loop arguments.
    if (isset($args['autoplay']) && '1' === $args['autoplay'] || $attr['autoplay'] || in_array('autoplay', $atts)) {
        $url = add_query_arg('autoplay', 1, $url);
    }
    if (isset($args['loop']) && '1' === $args['loop'] || $attr['loop'] || in_array('loop', $atts)) {
        $url = add_query_arg('loop', 1, $url);
    }
    $html = sprintf('<div class="embed-vimeo" style="text-align: center;"><iframe src="%1$s" width="%2$u" height="%3$u" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>', esc_url($url), esc_attr($width), esc_attr($height));
    /**
     * Filter the Vimeo player HTML.
     *
     * @module shortcodes
     *
     * @since 1.2.3
     *
     * @param string $html Embedded Vimeo player HTML.
     */
    $html = apply_filters('video_embed_html', $html);
    return $html;
}
Ejemplo n.º 12
0
/**
 * DailyMotion shortcode
 *
 * The documented shortcode is:
 * [dailymotion id=x8oma9]
 *
 * Possibilities, according to the old parsing regexp:
 * [dailymotion x8oma9]
 * [dailymotion=x8oma9]
 *
 * Hypothetical option, according to the old shortcode function is
 * [dailymotion id=1&title=2&user=3&video=4]
 *
 * 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
 * @return string html
 *
 */
function dailymotion_shortcode($atts)
{
    global $content_width;
    if (isset($atts[0])) {
        $id = ltrim($atts[0], '=');
        $atts['id'] = $id;
    } else {
        $params = shortcode_new_to_old_params($atts);
        parse_str($params, $atts_new);
        foreach ($atts_new as $k => $v) {
            $atts[$k] = $v;
        }
    }
    $atts = shortcode_atts(array('id' => '', 'width' => '', 'height' => '', 'title' => '', 'user' => '', 'video' => '', 'autoplay' => 0, 'endscreen-enable' => 1, 'mute' => 0, 'sharing-enable' => 1, 'start' => '', 'subtitles-default' => '', 'ui-highlight' => '', 'ui-logo' => 1, 'ui-start-screen-info' => 0, 'ui-theme' => ''), $atts, 'dailymotion');
    if (isset($atts['id']) && !empty($atts['id'])) {
        $id = urlencode($atts['id']);
    } else {
        return '<!--Dailymotion error: bad or missing ID-->';
    }
    /*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);
    $output = '';
    if (preg_match('/^[A-Za-z0-9]+$/', $id)) {
        $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())))) {
            $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']))) {
            /* 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;
}
Ejemplo n.º 13
0
function slideshare_shortcode($atts)
{
    global $content_width;
    $params = shortcode_new_to_old_params($atts);
    parse_str($params, $arguments);
    if (empty($arguments)) {
        return '<!-- SlideShare error: no arguments -->';
    }
    $attr = shortcode_atts(array('id' => '', 'w' => '', 'h' => '', 'fb' => '', 'mw' => '', 'mh' => '', 'sc' => '', 'pro' => '', 'style' => ''), $arguments);
    // check that the Slideshare ID contains letters, numbers and query strings
    $pattern = '/[^-_a-zA-Z0-9?=&]/';
    if (empty($attr['id']) || preg_match($pattern, $attr['id'])) {
        return '<!-- SlideShare error: id is missing or has illegal characters -->';
    }
    // check the width/height
    $w = $attr['w'];
    if (empty($w) && !empty($content_width)) {
        $w = intval($content_width);
    } elseif (!($w = intval($w)) || $w < 300 || $w > 1600) {
        $w = 425;
    } else {
        $w = intval($w);
    }
    $h = ceil($w * 348 / 425);
    // Note: user-supplied height is ignored.
    if (isset($attr['pro']) && $attr['pro']) {
        $source = 'https://www.slideshare.net/slidesharepro/' . $attr['id'];
    } else {
        $source = 'https://www.slideshare.net/slideshow/embed_code/' . $attr['id'];
    }
    if (isset($rel)) {
        $source = add_query_arg('rel', intval($rel), $source);
    }
    if (isset($startSlide)) {
        $source = add_query_arg('startSlide', intval($startSlide), $source);
    }
    $player = sprintf("<iframe src='%s' width='%d' height='%d'", esc_url($source), $w, $h);
    // check the frameborder
    if (!empty($attr['fb']) || '0' === $attr['fb']) {
        $player .= " frameborder='" . intval($attr['fb']) . "'";
    }
    // check the margin width; if not empty, cast as int
    if (!empty($attr['mw']) || '0' === $attr['mw']) {
        $player .= " marginwidth='" . intval($attr['mw']) . "'";
    }
    // check the margin height, if not empty, cast as int
    if (!empty($attr['mh']) || '0' === $attr['mh']) {
        $player .= " marginheight='" . intval($attr['mh']) . "'";
    }
    if (!empty($attr['style'])) {
        $player .= " style='" . esc_attr($attr['style']) . "'";
    }
    // check the scrollbar; cast as a lowercase string for comparison
    if (!empty($attr['sc'])) {
        $sc = strtolower($attr['sc']);
        if (in_array($sc, array('yes', 'no'))) {
            $player .= " scrolling='" . $sc . "'";
        }
    }
    $player .= ' allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>';
    return $player;
}