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


PHP _oembed_create_xml函数代码示例

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


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

示例1: test_oembed_create_xml

 function test_oembed_create_xml()
 {
     $actual = _oembed_create_xml(array('foo' => 'bar', 'bar' => 'baz', 'ping' => 'pong'));
     $expected = '<oembed><foo>bar</foo><bar>baz</bar><ping>pong</ping></oembed>';
     $this->assertStringEndsWith($expected, trim($actual));
     $actual = _oembed_create_xml(array('foo' => array('bar' => 'baz'), 'ping' => 'pong'));
     $expected = '<oembed><foo><bar>baz</bar></foo><ping>pong</ping></oembed>';
     $this->assertStringEndsWith($expected, trim($actual));
     $actual = _oembed_create_xml(array('foo' => array('bar' => array('ping' => 'pong')), 'hello' => 'world'));
     $expected = '<oembed><foo><bar><ping>pong</ping></bar></foo><hello>world</hello></oembed>';
     $this->assertStringEndsWith($expected, trim($actual));
     $actual = _oembed_create_xml(array(array('foo' => array('bar')), 'helloworld'));
     $expected = '<oembed><oembed><foo><oembed>bar</oembed></foo></oembed><oembed>helloworld</oembed></oembed>';
     $this->assertStringEndsWith($expected, trim($actual));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:15,代码来源:controller.php

示例2: _oembed_create_xml

/**
 * Creates an XML string from a given array.
 *
 * @since 4.4.0
 * @access private
 *
 * @param array            $data The original oEmbed response data.
 * @param SimpleXMLElement $node Optional. XML node to append the result to recursively.
 * @return string|false XML string on success, false on error.
 */
function _oembed_create_xml($data, $node = null)
{
    if (!is_array($data) || empty($data)) {
        return false;
    }
    if (null === $node) {
        $node = new SimpleXMLElement('<oembed></oembed>');
    }
    foreach ($data as $key => $value) {
        if (is_numeric($key)) {
            $key = 'oembed';
        }
        if (is_array($value)) {
            $item = $node->addChild($key);
            _oembed_create_xml($value, $item);
        } else {
            $node->addChild($key, esc_html($value));
        }
    }
    return $node->asXML();
}
开发者ID:nxty2011,项目名称:WordPress,代码行数:31,代码来源:embed-functions.php

示例3: xml_response

 /**
  * Print the oEmbed XML response.
  *
  * @since 4.4.0
  *
  * @param array $data The oEmbed response data.
  * @return string The XML response data.
  */
 public function xml_response($data)
 {
     if (!class_exists('SimpleXMLElement')) {
         status_header(501);
         return get_status_header_desc(501);
     }
     $result = _oembed_create_xml($data);
     // Bail if there's no XML.
     if (!$result) {
         status_header(501);
         return get_status_header_desc(501);
     }
     if (!headers_sent()) {
         header('Content-Type: text/xml; charset=' . get_option('blog_charset'));
     }
     return $result;
 }
开发者ID:hadywisam,项目名称:WordPress,代码行数:25,代码来源:class-wp-oembed-controller.php

示例4: oembed_xml_request

 /**
  * If oEmbed request wants XML, return XML instead of JSON.
  *
  * Basically a copy of {@link _oembed_rest_pre_serve_request()}. Unfortunate
  * that we have to duplicate this just for a URL check.
  *
  * @since 2.6.0
  *
  * @param bool                      $served  Whether the request has already been served.
  * @param WP_HTTP_ResponseInterface $result  Result to send to the client. Usually a WP_REST_Response.
  * @param WP_REST_Request           $request Request used to generate the response.
  * @param WP_REST_Server            $server  Server instance.
  * @return bool
  */
 public function oembed_xml_request($served, $result, $request, $server)
 {
     $params = $request->get_params();
     if (!isset($params['format']) || 'xml' !== $params['format']) {
         return $served;
     }
     // Validate URL against our oEmbed endpoint. If not valid, bail.
     // This is our mod to _oembed_rest_pre_serve_request().
     $query_params = $request->get_query_params();
     if (false === $this->validate_url_to_item_id($query_params['url'])) {
         return $served;
     }
     // Embed links inside the request.
     $data = $server->response_to_data($result, false);
     if (!class_exists('SimpleXMLElement')) {
         status_header(501);
         die(get_status_header_desc(501));
     }
     $result = _oembed_create_xml($data);
     // Bail if there's no XML.
     if (!$result) {
         status_header(501);
         return get_status_header_desc(501);
     }
     if (!headers_sent()) {
         $server->send_header('Content-Type', 'text/xml; charset=' . get_option('blog_charset'));
     }
     echo $result;
     return true;
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:44,代码来源:class-bp-core-oembed-extension.php

示例5: xml_response

 /**
  * Print the oEmbed XML response.
  *
  * @since 4.4.0
  *
  * @param array $data The oEmbed response data.
  * @return string The XML response data.
  */
 public function xml_response($data)
 {
     $result = _oembed_create_xml($data);
     // Bail if there's no XML.
     if (!$result) {
         status_header(501);
         return 'Not implemented';
     }
     if (!headers_sent()) {
         header('Content-Type: text/xml; charset=' . get_option('blog_charset'));
     }
     return $result;
 }
开发者ID:psycle,项目名称:wordpress,代码行数:21,代码来源:class-wp-oembed-controller.php


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