• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_embed_defaults函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_default_sizes

 function get_default_sizes()
 {
     $wp_embed_defaults = wp_embed_defaults();
     $height = intval(get_option('documentcloud_default_height', $wp_embed_defaults['height']));
     $width = intval(get_option('documentcloud_default_width', $wp_embed_defaults['width']));
     $full_width = intval(get_option('documentcloud_full_width', WP_DocumentCloud::DEFAULT_EMBED_FULL_WIDTH));
     return array('height' => $height, 'width' => $width, 'full_width' => $full_width);
 }
开发者ID:eyeseast,项目名称:wordpress-documentcloud,代码行数:8,代码来源:documentcloud.php


示例2: tamatebako_attachment_text

/**
 * Handles text attachments on their attachment pages.
 * @author Justin Tadlock <[email protected]>
 * @since 3.0.0
 */
function tamatebako_attachment_text($mime = '', $file = '')
{
    $embed_defaults = wp_embed_defaults();
    $text = '<object class="text" type="' . esc_attr($mime) . '" data="' . esc_url($file) . '" width="' . esc_attr($embed_defaults['width']) . '" height="' . esc_attr($embed_defaults['height']) . '">';
    $text .= '<param name="src" value="' . esc_url($file) . '" />';
    $text .= '</object>';
    return $text;
}
开发者ID:WPDevHQ,项目名称:nevertheless,代码行数:13,代码来源:attachment.php


示例3: bootstrap

 /**
  * Bootstrap this plugin
  *
  * @param string $file
  */
 public static function bootstrap($file)
 {
     self::$file = $file;
     Pronamic_Google_Maps_Plugin::bootstrap();
     Pronamic_Google_Maps_Widget::bootstrap();
     Pronamic_Google_Maps_Shortcodes::bootstrap();
     // Actions and hooks
     add_action('init', array(__CLASS__, 'init'));
     add_filter('parse_query', array(__CLASS__, 'parse_query'), 1000);
     // Options
     $embed_size = wp_embed_defaults();
     self::$defaultWidth = $embed_size['width'];
     self::$defaultHeight = $embed_size['height'];
 }
开发者ID:Warpsmith,项目名称:wp-pronamic-google-maps,代码行数:19,代码来源:Maps.php


示例4: shortcode

 function shortcode($attr, $url = '')
 {
     global $rte;
     if (empty($url)) {
         return '';
     }
     $rawattr = $attr;
     $attr = wp_parse_args($attr, wp_embed_defaults());
     // kses converts & into &amp; and we need to undo this
     // See http://core.trac.wordpress.org/ticket/11311
     $url = str_replace('&amp;', '&', $url);
     // Look for known internal handlers
     ksort($this->handlers);
     foreach ($this->handlers as $priority => $handlers) {
         foreach ($handlers as $id => $handler) {
             if (preg_match($handler['regex'], $url, $matches) && is_callable($handler['callback'])) {
                 if (false !== ($return = call_user_func($handler['callback'], $matches, $attr, $url, $rawattr))) {
                     return apply_filters('embed_handler_html', $return, $url, $attr);
                 }
             }
         }
     }
     // Check for a cached result (stored in the post meta)
     $cachekey = '_oembed_' . md5($url . serialize($attr));
     if ($this->usecache) {
         $cache = $this->rte->get_cache($cachekey);
         // Failures are cached
         if ('{{unknown}}' === $cache) {
             return $this->maybe_make_link($url);
         }
         if (!empty($cache)) {
             return apply_filters('embed_oembed_html', $cache, $url, $attr);
         }
     }
     // Use oEmbed to get the HTML
     $attr['discover'] = apply_filters('embed_oembed_discover', false) && current_user_can('unfiltered_html');
     $html = wp_oembed_get($url, $attr);
     // Cache the result
     $cache = $html ? $html : '{{unknown}}';
     $this->rte->set_cache($cachekey, $cache, 3600 * 24 * 7);
     // one week
     // If there was a result, return it
     if ($html) {
         return apply_filters('embed_oembed_html', $html, $url, $attr);
     }
     // Still unknown
     return $this->maybe_make_link($url);
 }
开发者ID:farvig,项目名称:wp-boilerplate,代码行数:48,代码来源:main.php


示例5: render

    protected function render()
    {
        $settings = $this->get_settings();
        if (empty($settings['link'])) {
            return;
        }
        $this->_current_instance = $settings;
        add_filter('oembed_result', [$this, 'filter_oembed_result'], 50, 3);
        $video_html = wp_oembed_get($settings['link']['url'], wp_embed_defaults());
        remove_filter('oembed_result', [$this, 'filter_oembed_result'], 50);
        if ($video_html) {
            ?>
			<div class="elementor-soundcloud-wrapper">
				<?php 
            echo $video_html;
            ?>
			</div>
		<?php 
        }
    }
开发者ID:pojome,项目名称:elementor,代码行数:20,代码来源:audio.php


示例6: test_shortcode_should_cache_failure_in_post_meta_for_known_post

 public function test_shortcode_should_cache_failure_in_post_meta_for_known_post()
 {
     $GLOBALS['post'] = $this->factory()->post->create_and_get();
     $url = 'https://example.com/';
     $expected = '<a href="' . esc_url($url) . '">' . esc_html($url) . '</a>';
     $key_suffix = md5($url . serialize(wp_embed_defaults($url)));
     $cachekey = '_oembed_' . $key_suffix;
     $cachekey_time = '_oembed_time_' . $key_suffix;
     add_filter('pre_oembed_result', '__return_empty_string');
     $actual = $this->wp_embed->shortcode(array(), $url);
     remove_filter('pre_oembed_result', '__return_empty_string');
     $this->assertEquals($expected, $actual);
     $this->assertEquals('{{unknown}}', get_post_meta($GLOBALS['post']->ID, $cachekey, true));
     $this->assertEmpty(get_post_meta($GLOBALS['post']->ID, $cachekey_time, true));
     // Result should be cached.
     $actual = $this->wp_embed->shortcode(array(), $url);
     $this->assertEquals($expected, $actual);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:18,代码来源:WpEmbed.php


示例7: shortcode

 /**
  * The {@link do_shortcode()} callback function.
  *
  * Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of the registered embed handlers.
  * If none of the regex matches and it's enabled, then the URL will be given to the {@link WP_oEmbed} class.
  *
  * @uses wp_oembed_get()
  * @uses wp_parse_args()
  * @uses wp_embed_defaults()
  * @uses WP_Embed::maybe_make_link()
  * @uses get_option()
  * @uses current_user_can()
  * @uses wp_cache_get()
  * @uses wp_cache_set()
  * @uses get_post_meta()
  * @uses update_post_meta()
  *
  * @param array $attr Shortcode attributes.
  * @param string $url The URL attempting to be embedded.
  * @return string The embed HTML on success, otherwise the original URL.
  */
 function shortcode($attr, $url = '')
 {
     global $post;
     if (empty($url)) {
         return '';
     }
     $rawattr = $attr;
     $attr = wp_parse_args($attr, wp_embed_defaults());
     // kses converts & into &amp; and we need to undo this
     // See http://core.trac.wordpress.org/ticket/11311
     $url = str_replace('&amp;', '&', $url);
     // Look for known internal handlers
     ksort($this->handlers);
     foreach ($this->handlers as $priority => $handlers) {
         foreach ($handlers as $id => $handler) {
             if (preg_match($handler['regex'], $url, $matches) && is_callable($handler['callback'])) {
                 if (false !== ($return = call_user_func($handler['callback'], $matches, $attr, $url, $rawattr))) {
                     return apply_filters('embed_handler_html', $return, $url, $attr);
                 }
             }
         }
     }
     $post_ID = !empty($post->ID) ? $post->ID : null;
     if (!empty($this->post_ID)) {
         // Potentially set by WP_Embed::cache_oembed()
         $post_ID = $this->post_ID;
     }
     // Unknown URL format. Let oEmbed have a go.
     if ($post_ID) {
         // Check for a cached result (stored in the post meta)
         $cachekey = '_oembed_' . md5($url . serialize($attr));
         if ($this->usecache) {
             $cache = get_post_meta($post_ID, $cachekey, true);
             // Failures are cached
             if ('{{unknown}}' === $cache) {
                 return $this->maybe_make_link($url);
             }
             if (!empty($cache)) {
                 return apply_filters('embed_oembed_html', $cache, $url, $attr, $post_ID);
             }
         }
         // Use oEmbed to get the HTML
         $attr['discover'] = apply_filters('embed_oembed_discover', false) && author_can($post_ID, 'unfiltered_html');
         $html = wp_oembed_get($url, $attr);
         // Cache the result
         $cache = $html ? $html : '{{unknown}}';
         update_post_meta($post_ID, $cachekey, $cache);
         // If there was a result, return it
         if ($html) {
             return apply_filters('embed_oembed_html', $html, $url, $attr, $post_ID);
         }
     }
     // Still unknown
     return $this->maybe_make_link($url);
 }
开发者ID:nzeyimana,项目名称:WordPress,代码行数:76,代码来源:media.php


示例8: shortcode

 /**
  * The {@link do_shortcode()} callback function.
  *
  * Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of the registered embed handlers.
  * Next, checks the URL against the regex of registered {@link WP_oEmbed} providers if oEmbed discovery is false.
  * If none of the regex matches and it's enabled, then the URL will be passed to {@link BP_Embed::parse_oembed()} for oEmbed parsing.
  *
  * @uses wp_parse_args()
  * @uses wp_embed_defaults()
  * @uses current_user_can()
  * @uses _wp_oembed_get_object()
  * @uses WP_Embed::maybe_make_link()
  *
  * @param array $attr Shortcode attributes.
  * @param string $url The URL attempting to be embeded.
  * @return string The embed HTML on success, otherwise the original URL.
  */
 function shortcode($attr, $url = '')
 {
     if (empty($url)) {
         return '';
     }
     $rawattr = $attr;
     $attr = wp_parse_args($attr, wp_embed_defaults());
     // kses converts & into &amp; and we need to undo this
     // See http://core.trac.wordpress.org/ticket/11311
     $url = str_replace('&amp;', '&', $url);
     // Look for known internal handlers
     ksort($this->handlers);
     foreach ($this->handlers as $priority => $handlers) {
         foreach ($handlers as $hid => $handler) {
             if (preg_match($handler['regex'], $url, $matches) && is_callable($handler['callback'])) {
                 if (false !== ($return = call_user_func($handler['callback'], $matches, $attr, $url, $rawattr))) {
                     return apply_filters('embed_handler_html', $return, $url, $attr);
                 }
             }
         }
     }
     // Get object ID
     $id = apply_filters('embed_post_id', 0);
     // Is oEmbed discovery on?
     $attr['discover'] = apply_filters('bp_embed_oembed_discover', false) && current_user_can('unfiltered_html');
     // Set up a new WP oEmbed object to check URL with registered oEmbed providers
     require_once ABSPATH . WPINC . '/class-oembed.php';
     $oembed_obj = _wp_oembed_get_object();
     // If oEmbed discovery is true, skip oEmbed provider check
     $is_oembed_link = false;
     if (!$attr['discover']) {
         foreach ((array) $oembed_obj->providers as $provider_matchmask => $provider) {
             $regex = ($is_regex = $provider[1]) ? $provider_matchmask : '#' . str_replace('___wildcard___', '(.+)', preg_quote(str_replace('*', '___wildcard___', $provider_matchmask), '#')) . '#i';
             if (preg_match($regex, $url)) {
                 $is_oembed_link = true;
             }
         }
         // If url doesn't match a WP oEmbed provider, stop parsing
         if (!$is_oembed_link) {
             return $this->maybe_make_link($url);
         }
     }
     return $this->parse_oembed($id, $url, $attr, $rawattr);
 }
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:61,代码来源:bp-core-classes.php


示例9: fetch

 /**
  * Connects to a oEmbed provider and returns the result.
  *
  * @param string $provider The URL to the oEmbed provider.
  * @param string $url The URL to the content that is desired to be embedded.
  * @param array $args Optional arguments. Usually passed from a shortcode.
  * @return bool|object False on failure, otherwise the result in the form of an object.
  */
 function fetch($provider, $url, $args = '')
 {
     $args = wp_parse_args($args, wp_embed_defaults());
     $provider = add_query_arg('format', 'json', $provider);
     // JSON is easier to deal with than XML
     $provider = add_query_arg('maxwidth', $args['width'], $provider);
     $provider = add_query_arg('maxheight', $args['height'], $provider);
     $provider = add_query_arg('url', urlencode($url), $provider);
     if (!($result = wp_remote_retrieve_body(wp_remote_get($provider)))) {
         return false;
     }
     $result = trim($result);
     // JSON?
     // Example content: http://vimeo.com/api/oembed.json?url=http%3A%2F%2Fvimeo.com%2F240975
     if ($data = json_decode($result)) {
         return $data;
     } elseif (function_exists('simplexml_load_string')) {
         $errors = libxml_use_internal_errors('true');
         $data = simplexml_load_string($result);
         libxml_use_internal_errors($errors);
         if (is_object($data)) {
             return $data;
         }
     }
     return false;
 }
开发者ID:jao,项目名称:jpcamargo,代码行数:34,代码来源:class-oembed.php


示例10: render

    protected function render()
    {
        $settings = $this->get_settings();
        if ('hosted' !== $settings['video_type']) {
            add_filter('oembed_result', [$this, 'filter_oembed_result'], 50, 3);
            $video_link = 'youtube' === $settings['video_type'] ? $settings['link'] : $settings['vimeo_link'];
            if (empty($video_link)) {
                return;
            }
            $video_html = wp_oembed_get($video_link, wp_embed_defaults());
            remove_filter('oembed_result', [$this, 'filter_oembed_result'], 50);
        } else {
            $video_html = wp_video_shortcode($this->get_hosted_params());
        }
        if ($video_html) {
            ?>
			<div class="elementor-video-wrapper">
				<?php 
            echo $video_html;
            if ($this->has_image_overlay()) {
                ?>
					<div class="elementor-custom-embed-image-overlay" style="background-image: url(<?php 
                echo $settings['image_overlay']['url'];
                ?>
);">
						<?php 
                if ('yes' === $settings['show_play_icon']) {
                    ?>
							<div class="elementor-custom-embed-play">
								<i class="fa fa-play-circle"></i>
							</div>
						<?php 
                }
                ?>
					</div>
				<?php 
            }
            ?>
			</div>
		<?php 
        } else {
            echo $settings['link'];
        }
    }
开发者ID:pojome,项目名称:elementor,代码行数:44,代码来源:video.php


示例11: markdown

 /**
  * A very simple markdown parser.
  *
  * @since 150113 First documented version.
  *
  * @param string $string Input string to convert.
  * @param array  $args   Any additional behavioral args.
  *
  * @return string Markdown converted to HTML markup.
  */
 public function markdown($string, array $args = [])
 {
     if (!($string = trim((string) $string))) {
         return $string;
         // Not possible.
     }
     $default_args = ['oembed' => false, 'breaks' => true, 'no_p' => false];
     $args = array_merge($default_args, $args);
     $args = array_intersect_key($args, $default_args);
     $oembed = (bool) $args['oembed'];
     $breaks = (bool) $args['breaks'];
     $no_p = (bool) $args['no_p'];
     if ($oembed && strpos($string, '://') !== false) {
         $_spcsm = $this->spcsmTokens($string, [], __FUNCTION__);
         $_oembed_args = array_merge(wp_embed_defaults(), ['discover' => false]);
         $_spcsm['string'] = preg_replace_callback('/^\\s*(https?:\\/\\/[^\\s"]+)\\s*$/im', function ($m) use($_oembed_args) {
             $oembed = wp_oembed_get($m[1], $_oembed_args);
             return $oembed ? $oembed : $m[0];
         }, $_spcsm['string']);
         $string = $this->spcsmRestore($_spcsm);
         unset($_spcsm, $_oembed_args);
         // Housekeeping.
     }
     if (is_null($parsedown =& $this->cacheKey(__FUNCTION__, 'parsedown'))) {
         $parsedown = new \ParsedownExtra();
         // Singleton.
     }
     $parsedown->setBreaksEnabled($breaks);
     $html = $parsedown->text($string);
     if ($no_p) {
         // Remove `<p></p>` wrap?
         $html = preg_replace('/^\\<p\\>/i', '', $html);
         $html = preg_replace('/\\<\\/p\\>$/i', '', $html);
     }
     return $html;
     // Gotta love Parsedown :-)
 }
开发者ID:websharks,项目名称:comment-mail,代码行数:47,代码来源:UtilsString.php


示例12: fetch

 /**
  * Connects to a oEmbed provider and returns the result.
  *
  * @param string $provider The URL to the oEmbed provider.
  * @param string $url The URL to the content that is desired to be embedded.
  * @param array $args Optional arguments. Usually passed from a shortcode.
  * @return bool|object False on failure, otherwise the result in the form of an object.
  */
 public function fetch($provider, $url, $args = '')
 {
     $args = wp_parse_args($args, wp_embed_defaults($url));
     $provider = add_query_arg('maxwidth', (int) $args['width'], $provider);
     $provider = add_query_arg('maxheight', (int) $args['height'], $provider);
     $provider = add_query_arg('url', urlencode($url), $provider);
     /**
      * Filter the oEmbed URL to be fetched.
      *
      * @since 2.9.0
      *
      * @param string $provider URL of the oEmbed provider.
      * @param string $url      URL of the content to be embedded.
      * @param array  $args     Optional arguments, usually passed from a shortcode.
      */
     $provider = apply_filters('oembed_fetch_url', $provider, $url, $args);
     foreach (array('json', 'xml') as $format) {
         $result = $this->_fetch_with_format($provider, $format);
         if (is_wp_error($result) && 'not-implemented' == $result->get_error_code()) {
             continue;
         }
         return $result && !is_wp_error($result) ? $result : false;
     }
     return false;
 }
开发者ID:catalinmiron,项目名称:WordPress,代码行数:33,代码来源:class-oembed.php


示例13: shortcode

 /**
  * The {@link do_shortcode()} callback function.
  *
  * Attempts to convert a URL into embed HTML. Starts by checking the
  * URL against the regex of the registered embed handlers. Next, checks
  * the URL against the regex of registered {@link WP_oEmbed} providers
  * if oEmbed discovery is false. If none of the regex matches and it's
  * enabled, then the URL will be passed to {@link BP_Embed::parse_oembed()}
  * for oEmbed parsing.
  *
  * @uses wp_parse_args()
  * @uses wp_embed_defaults()
  * @uses current_user_can()
  * @uses _wp_oembed_get_object()
  * @uses WP_Embed::maybe_make_link()
  *
  * @param array  $attr Shortcode attributes.
  * @param string $url  The URL attempting to be embeded.
  * @return string The embed HTML on success, otherwise the original URL.
  */
 public function shortcode($attr, $url = '')
 {
     if (empty($url)) {
         return '';
     }
     $rawattr = $attr;
     $attr = wp_parse_args($attr, wp_embed_defaults());
     // Use kses to convert & into &amp; and we need to undo this
     // See https://core.trac.wordpress.org/ticket/11311.
     $url = str_replace('&amp;', '&', $url);
     // Look for known internal handlers.
     ksort($this->handlers);
     foreach ($this->handlers as $priority => $handlers) {
         foreach ($handlers as $hid => $handler) {
             if (preg_match($handler['regex'], $url, $matches) && is_callable($handler['callback'])) {
                 if (false !== ($return = call_user_func($handler['callback'], $matches, $attr, $url, $rawattr))) {
                     /**
                      * Filters the oEmbed handler result for the provided URL.
                      *
                      * @since 1.5.0
                      *
                      * @param string $return Handler callback for the oEmbed.
                      * @param string $url    URL attempting to be embedded.
                      * @param array  $attr   Shortcode attributes.
                      */
                     return apply_filters('embed_handler_html', $return, $url, $attr);
                 }
             }
         }
     }
     /**
      * Filters the embed object ID.
      *
      * @since 1.5.0
      *
      * @param int $value Value of zero.
      */
     $id = apply_filters('embed_post_id', 0);
     $unfiltered_html = current_user_can('unfiltered_html');
     $default_discovery = false;
     // Since 4.4, WordPress is now an oEmbed provider.
     if (function_exists('wp_oembed_register_route')) {
         $unfiltered_html = true;
         $default_discovery = true;
     }
     /**
      * Filters whether or not oEmbed discovery is on.
      *
      * @since 1.5.0
      * @since 2.5.0 Default status of oEmbed discovery has been switched
      *              to true to apply changes introduced in WordPress 4.4
      *
      * @param bool $default_discovery Current status of oEmbed discovery.
      */
     $attr['discover'] = apply_filters('bp_embed_oembed_discover', $default_discovery) && $unfiltered_html;
     // Set up a new WP oEmbed object to check URL with registered oEmbed providers.
     require_once ABSPATH . WPINC . '/class-oembed.php';
     $oembed_obj = _wp_oembed_get_object();
     // If oEmbed discovery is true, skip oEmbed provider check.
     $is_oembed_link = false;
     if (!$attr['discover']) {
         foreach ((array) $oembed_obj->providers as $provider_matchmask => $provider) {
             $regex = ($is_regex = $provider[1]) ? $provider_matchmask : '#' . str_replace('___wildcard___', '(.+)', preg_quote(str_replace('*', '___wildcard___', $provider_matchmask), '#')) . '#i';
             if (preg_match($regex, $url)) {
                 $is_oembed_link = true;
             }
         }
         // If url doesn't match a WP oEmbed provider, stop parsing.
         if (!$is_oembed_link) {
             return $this->maybe_make_link($url);
         }
     }
     return $this->parse_oembed($id, $url, $attr, $rawattr);
 }
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:94,代码来源:class-bp-embed.php


示例14: shortcode

 function shortcode($attr, $url = '')
 {
     global $post;
     if (empty($url)) {
         return '';
     }
     $rawattr = $attr;
     $attr = wp_parse_args($attr, wp_embed_defaults());
     // kses converts & into &amp; and we need to undo this
     // See http://core.trac.wordpress.org/ticket/11311
     $url = str_replace('&amp;', '&', $url);
     // Look for known internal handlers
     ksort($this->handlers);
     foreach ($this->handlers as $priority => $handlers) {
         foreach ($handlers as $id => $handler) {
             if (preg_match($handler['regex'], $url, $matches) && is_callable($handler['callback'])) {
                 if (false !== ($return = call_user_func($handler['callback'], $matches, $attr, $url, $rawattr))) {
                     return apply_filters('embed_handler_html', $return, $url, $attr);
                 }
             }
         }
     }
     $transient_name = $this->widget_id . '_' . md5($url);
     // Store the value of the disable_related option.
     // If it changes we need to clear transient data containing the html
     // and update the transient containing the disable_related value
     $related_transient = get_transient($transient_name . '_related');
     if (false !== $related_transient && $related_transient != $this->disable_related) {
         delete_transient($transient_name);
         set_transient($transient_name . '_related', $this->disable_related, 60 * 60 * 12);
     }
     $transient = get_transient($transient_name);
     // return the transient html value if its available
     if (false !== $transient) {
         return apply_filters('embed_oembed_html', $transient, $url, $attr, $post_ID);
     }
     // Use oEmbed to get the HTML
     $attr['discover'] = apply_filters('embed_oembed_discover', false) && author_can($post_ID, 'unfiltered_html');
     $html = wp_oembed_get($url, $attr);
     // If there was a result, return it
     if ($html) {
         // if 'youtube' is found in the html and disable related is true, add rel=0 paramater
         if (false !== strpos($html, 'youtube') && true == $this->disable_related) {
             $html = $this->disable_youtube_related($html);
         }
         set_transient($transient_name, $html, 60 * 60 * 12);
         // We need to know if the disable_related value of this widget changes
         // and clear transient data when it does
         set_transient($transient_name . '_related', $this->disable_related, 60 * 60 * 12);
         return apply_filters('embed_oembed_html', $html, $url, $attr, $post_ID);
     }
     return $this->maybe_make_link($url);
 }
开发者ID:AnushkaKRajasingha,项目名称:confusedgirlinthecity,代码行数:53,代码来源:custom-widget.php


示例15: hybrid_text_attachment

/**
 * Handles text attachments on their attachment pages.  Uses the `<object>` element to embed media
 * in the pages.
 *
 * @since  0.3.0
 * @access public
 * @param  string $mime attachment mime type
 * @param  string $file attachment file URL
 * @return string
 */
function hybrid_text_attachment($mime = '', $file = '')
{
    $embed_defaults = wp_embed_defaults();
    return sprintf('<object type="%1$s" data="%2$s" width="%3$s" height="%4$s"><param name="src" value="%2$s" /></object>', esc_attr($mime), esc_url($file), absint($embed_defaults['width']), absint($embed_defaults['height']));
}
开发者ID:ifte510,项目名称:hybrid-core,代码行数:15,代码来源:template-media.php


示例16: shortcode

	/**
	 * The {@link do_shortcode()} callback function.
	 *
	 * Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of the registered embed handlers.
	 * If none of the regex matches and it's enabled, then the URL will be given to the {@link WP_oEmbed} class.
	 *
	 * @uses wp_oembed_get()
	 * @uses wp_parse_args()
	 * @uses wp_embed_defaults()
	 * @uses WP_Embed::maybe_make_link()
	 * @uses get_option()
	 * @uses author_can()
	 * @uses wp_cache_get()
	 * @uses wp_cache_set()
	 * @uses get_post_meta()
	 * @uses update_post_meta()
	 *
	 * @param array $attr Shortcode attributes.
	 * @param string $url The URL attempting to be embedded.
	 * @return string The embed HTML on success, otherwise the original URL.
	 */
	function shortcode( $attr, $url = '' ) {
		$post = get_post();

		if ( empty( $url ) )
			return '';

		$rawattr = $attr;
		$attr = wp_parse_args( $attr, wp_embed_defaults() );

		// kses converts & into &amp; and we need to undo this
		// See http://core.trac.wordpress.org/ticket/11311
		$url = str_replace( '&amp;', '&', $url );

		// Look for known internal handlers
		ksort( $this->handlers );
		foreach ( $this->handlers as $priority => $handlers ) {
			foreach ( $handlers as $id => $handler ) {
				if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
					if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) )
						/**
						 * Filter the returned embed handler.
						 *
						 * @since 2.9.0
						 *
						 * @param mixed  $return The shortcode callback function to call.
						 * @param string $url    The attempted embed URL.
						 * @param array  $attr   An array of shortcode attributes.
						 */
						return apply_filters( 'embed_handler_html', $return, $url, $attr );
				}
			}
		}

		$post_ID = ( ! empty( $post->ID ) ) ? $post->ID : null;
		if ( ! empty( $this->post_ID ) ) // Potentially set by WP_Embed::cache_oembed()
			$post_ID = $this->post_ID;

		// Unknown URL format. Let oEmbed have a go.
		if ( $post_ID ) {

			// Check for a cached result (stored in the post meta)
			$cachekey = '_oembed_' . md5( $url . serialize( $attr ) );
			if ( $this->usecache ) {
				$cache = get_post_meta( $post_ID, $cachekey, true );

				// Failures are cached
				if ( '{{unknown}}' === $cache )
					return $this->maybe_make_link( $url );

				if ( ! empty( $cache ) )
					/**
					 * Filter the cached oEmbed HTML.
					 *
					 * @since 2.9.0
					 *
					 * @param mixed  $cache   The cached HTML result, stored in post meta.
					 * @param string $url     The attempted embed URL.
					 * @param array  $attr    An array of shortcode attributes.
					 * @param int    $post_ID Post ID.
					 */
					return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID );
			}

			/**
			 * Filter whether to inspect the given URL for discoverable <link> tags.
			 *
			 * @see WP_oEmbed::discover()
			 *
			 * @param bool false Whether to enable <link> tag discovery. Default false.
			 */
			$attr['discover'] = ( apply_filters( 'embed_oembed_discover', false ) && author_can( $post_ID, 'unfiltered_html' ) );

			// Use oEmbed to get the HTML
			$html = wp_oembed_get( $url, $attr );

			// Cache the result
			$cache = ( $html ) ? $html : '{{unknown}}';
			update_post_meta( $post_ID, $cachekey, $cache );

//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:class-wp-embed.php


示例17: shortcode

 /**
  * The {@link do_shortcode()} callback function.
  *
  * Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of the registered embed handlers.
  * If none of the regex matches and it's enabled, then the URL will be given to the {@link WP_oEmbed} class.
  *
  * @uses wp_oembed_get()
  * @uses wp_parse_args()
  * @uses wp_embed_defaults()
  * @uses WP_Embed::maybe_make_link()
  * @uses get_option()
  * @uses current_user_can()
  * @uses wp_cache_get()
  * @uses wp_cache_set()
  * @uses get_post_meta()
  * @uses update_post_meta()
  *
  * @param array $attr Shortcode attributes.
  * @param string $url The URL attempting to be embeded.
  * @return string The embed HTML on success, otherwise the original URL.
  */
 function shortcode($attr, $url = '')
 {
     global $post, $_wp_using_ext_object_cache;
     if (empty($url)) {
         return '';
     }
     $rawattr = $attr;
     $attr = wp_parse_args($attr, wp_embed_defaults());
     // Look for known internal handlers
     ksort($this->handlers);
     foreach ($this->handlers as $priority => $handlers) {
         foreach ($handlers as $id => $handler) {
             if (preg_match($handler['regex'], $url, $matches) && is_callable($handler['callback'])) {
                 if (false !== ($return = call_user_func($handler['callback'], $matches, $attr, $url, $rawattr))) {
                     return $return;
                 }
             }
         }
     }
     $post_ID = !empty($post->ID) ? $post->ID : null;
     if (!empty($this->post_ID)) {
         // Potentially set by WP_Embed::cache_oembed()
         $post_ID = $this->post_ID;
     }
     // Unknown URL format. Let oEmbed have a go.
     if ($post_ID && get_option('embed_useoembed')) {
         // Check for a cached result (stored in the post meta)
         $cachekey = '_oembed_' . md5($url . implode('|', $attr));
         if ($this->usecache) {
             $cache = $_wp_using_ext_object_cache ? wp_cache_get("{$post_ID}_{$cachekey}", 'oembed') : get_post_meta($post_ID, $cachekey, true);
             // Failures are cached
             if ('{{unknown}}' === $cache) {
                 return $this->maybe_make_link($url);
             }
             if (!empty($cache)) {
                 return $cache;
             }
         }
         // Use oEmbed to get the HTML
         $attr['discover'] = author_can($post_ID, 'unfiltered_html');
         $html = wp_oembed_get($url, $attr);
         // Cache the result
         $cache = $html ? $html : '{{unknown}}';
         if ($_wp_using_ext_object_cache) {
             wp_cache_set("{$post_ID}_{$cachekey}", $cache, 'oembed');
         } else {
             update_post_meta($post_ID, $cachekey, $cache);
         }
         // If there was a result, return it
         if ($html) {
             return $html;
         }
     }
     // Still unknown
     return $this->maybe_make_link($url);
 }
开发者ID:jao,项目名称:jpcamargo,代码行数:77,代码来源:media.php


示例18: bp_activity_embed_media

/**
 * Outputs the first embedded item in the activity oEmbed template.
 *
 * @since 2.6.0
 */
function bp_activity_embed_media()
{
    // Bail if oEmbed request explicitly hides media.
    if (isset($_GET['hide_media']) && true == wp_validate_boolean($_GET['hide_media'])) {
        /**
         * Do something after media is rendered for an activity oEmbed item.
         *
         * @since 2.6.0
         */
        do_action('bp_activity_embed_after_media');
        return;
    }
    /**
     * Should we display media in the oEmbed template?
     *
     * @since 2.6.0
     *
     * @param bool $retval Defaults to true.
     */
    $allow_media = apply_filters('bp_activity_embed_display_media', true);
    // Find oEmbeds from only WP registered providers.
    bp_remove_all_filters('oembed_providers');
    $media = bp_core_extract_media_from_content($GLOBALS['activities_template']->activity->content, 'embeds');
    bp_restore_all_filters('oembed_providers');
    // oEmbeds have precedence over inline video / audio.
    if (isset($media['embeds']) && true === $allow_media) {
        // Autoembed first URL.
        $oembed_defaults = wp_embed_defaults();
        $oembed_args = array('width' => $oembed_defaults['width'], 'height' => $oembed_defaults['height'], 'discover' => true);
        $url = $media['embeds'][0]['url'];
        $cachekey = '_oembed_response_' . md5($url . serialize($oembed_args));
        // Try to fetch oEmbed response from meta.
        $oembed = bp_activity_get_meta(bp_get_activity_id(), $cachekey);
        // No cache, so fetch full oEmbed response now!
        if ('' === $oembed) {
            $o = _wp_oembed_get_object();
            $oembed = $o->fetch($o->get_provider($url, $oembed_args), $url, $oembed_args);
            // Cache oEmbed response.
            bp_activity_update_meta(bp_get_activity_id(), $cachekey, $oembed);
        }
        $content = '';
        /**
         * Filters the default embed display max width.
         *
         * This is used if the oEmbed response does not return a thumbnail width.
         *
         * @since 2.6.0
         *
         * @param int $width.
         */
        $width = (int) apply_filters('bp_activity_embed_display_media_width', 550);
        // Set thumbnail.
        if ('photo' === $oembed->type) {
            $thumbnail = $oembed->url;
        } elseif (isset($oembed->thumbnail_url)) {
            $thumbnail = $oembed->thumbnail_url;
            /* Non-oEmbed standard attributes */
            // Mixcloud
        } elseif (isset($oembed->image)) {
            $thumbnail = $oembed->image;
            // ReverbNation
        } elseif (isset($oembed->{'thumbnail-url'})) {
            $thumbnail = $oembed->{'thumbnail-url'};
        }
        // Display thumb and related oEmbed meta.
        if (true === isset($thumbnail)) {
            $play_icon = $caption = '';
            // Add play icon for non-photos.
            if ('photo' !== $oembed->type) {
                /**
                 * ion-play icon from Ionicons.
                 *
                 * @link    http://ionicons.com/
                 * @license MIT
                 */
                $play_icon = <<<EOD
<svg id="Layer_1" style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M405.2,232.9L126.8,67.2c-3.4-2-6.9-3.2-10.9-3.2c-10.9,0-19.8,9-19.8,20H96v344h0.1c0,11,8.9,20,19.8,20  c4.1,0,7.5-1.4,11.2-3.4l278.1-165.5c6.6-5.5,10.8-13.8,10.8-23.1C416,246.7,411.8,238.5,405.2,232.9z"/></svg>
EOD;
                $play_icon = sprintf('<a rel="nofollow" class="play-btn" href="%1$s" onclick="top.location.href=\'%1$s\'">%2$s</a>', esc_url($url), $play_icon);
            }
            // Thumb width
            $thumb_width = isset($oembed->thumbnail_width) && 'photo' !== $oembed->type && (int) $oembed->thumbnail_width < 550 ? (int) $oembed->thumbnail_width : $width;
            $float_width = 350;
            // Set up thumb.
            $content = sprintf('<div class="thumb" style="max-width:%1$spx">%2$s<a href="%3$s" rel="nofollow" onclick="top.location.href=\'%3$s\'"><img src="%4$s" /></a></div>', $thumb_width, $play_icon, esc_url($url), esc_url($thumbnail));
            // Show title.
            if (isset($oembed->title)) {
                $caption .= sprintf('<p class="caption-title"><strong>%s</strong></p>', apply_filters('single_post_title', $oembed->title));
            }
            // Show description (non-oEmbed standard)
            if (isset($oembed->description)) {
                $caption .= sprintf('<div class="caption-description">%s</div>', apply_filters('bp_activity_get_embed_excerpt', $oembed->description));
            }
            // Show author info.
            if (isset($oembed->provider_name) && isset($oembed->author_name)) {
//.........这里部分代码省略.........
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:101,代码来源:bp-activity-embeds.php


示例19: shortcode

 /**
  * The {@link do_shortcode()} callback function.
  *
  * Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of the registered embed handlers.
  * If none of the regex matches and it's enabled, then the URL will be given to the {@link WP_oEmbed} class.
  *
  * @param array $attr {
  *     Shortcode attributes. Optional.
  *
  *     @type int $width  Width of the embed in pixels.
  *     @type int $height Height of the embed in pixels.
  * }
  * @param string $url The URL attempting to be embedded.
  * @return string|false The embed HTML on success, otherwise the original URL.
  *                      `->maybe_make_link()` can return false on failure.
  */
 public function shortcode($attr, $url = '')
 {
     $post = get_post();
     if (empty($url) && !empty($attr['src'])) {
         $url = $attr['src'];
     }
     $this->last_url = $url;
     if (empty($url)) {
         $this->last_attr = $attr;
         return '';
     }
     $rawattr = $attr;
     $attr = wp_parse_args($attr, wp_embed_defaults($url));
     $this->last_attr = $attr;
     // kses converts & into &amp; and we need to undo this
     // See https://core.trac.wordpress.org/ticket/11311
     $url = str_rep 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_embed_register_handler函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_editor函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap