当前位置: 首页>>代码示例>>PHP>>正文


PHP shortcode_new_to_old_params函数代码示例

本文整理汇总了PHP中shortcode_new_to_old_params函数的典型用法代码示例。如果您正苦于以下问题:PHP shortcode_new_to_old_params函数的具体用法?PHP shortcode_new_to_old_params怎么用?PHP shortcode_new_to_old_params使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了shortcode_new_to_old_params函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: slideshare_shortcode

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;
}
开发者ID:moscarar,项目名称:cityhow,代码行数:30,代码来源:slideshare.php

示例2: dailymotion_shortcode

/**
 * 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;
}
开发者ID:valiror,项目名称:sharingdais_demo1,代码行数:55,代码来源:dailymotion.php

示例3: slideshare_shortcode

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;
}
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:58,代码来源:slideshare.php

示例4: vimeo_shortcode

/**
 * 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;
}
开发者ID:moushegh,项目名称:blog-source-configs,代码行数:55,代码来源:vimeo.php

示例5: shortcode

 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));
 }
开发者ID:thenextweb,项目名称:amp-wp,代码行数:15,代码来源:class-amp-youtube-embed.php

示例6: vimeo_shortcode

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;
}
开发者ID:Bencheci,项目名称:blueRavenStudiosProject,代码行数:44,代码来源:vimeo.php

示例7: vimeo_shortcode

/**
 * 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;
}
开发者ID:ejoan,项目名称:erikajoan.com,代码行数:50,代码来源:vimeo.php

示例8: jetpack_slide_embed

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>";
    }
}
开发者ID:Bencheci,项目名称:blueRavenStudiosProject,代码行数:24,代码来源:slide.php

示例9: youtube_shortcode

function youtube_shortcode($atts)
{
    return youtube_id(isset($atts[0]) ? ltrim($atts[0], '=') : shortcode_new_to_old_params($atts));
}
开发者ID:phototech,项目名称:sailvenice,代码行数:4,代码来源:youtube.php

示例10: youtube_shortcode

function youtube_shortcode($atts)
{
    if (isset($atts[0])) {
        $src = ltrim($atts[0], '=');
    } else {
        $src = shortcode_new_to_old_params($atts);
    }
    return youtube_id($src);
}
开发者ID:Bencheci,项目名称:blueRavenStudiosProject,代码行数:9,代码来源:youtube.php

示例11: vimeo_shortcode

/**
 * 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;
}
开发者ID:laurelfulford,项目名称:jetpack,代码行数:90,代码来源:vimeo.php

示例12: dailymotion_shortcode

/**
 * 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)) {
//.........这里部分代码省略.........
开发者ID:iamtakashi,项目名称:jetpack,代码行数:101,代码来源:dailymotion.php

示例13: slideshare_shortcode

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;
}
开发者ID:pcuervo,项目名称:wp-carnival,代码行数:62,代码来源:slideshare.php


注:本文中的shortcode_new_to_old_params函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。