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

PHP wp_http_validate_url函数代码示例

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

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



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

示例1: pingback_ping_source_uri

/**
 * Default filter attached to pingback_ping_source_uri to validate the pingback's Source URI
 *
 * @since 3.5.1
 * @see wp_http_validate_url()
 *
 * @param string $source_uri
 * @return string
 */
function pingback_ping_source_uri($source_uri)
{
    return (string) wp_http_validate_url($source_uri);
}
开发者ID:hadywisam,项目名称:WordPress,代码行数:13,代码来源:comment-functions.php


示例2: request


//.........这里部分代码省略.........
      *
      * @param array  $r   An array of HTTP request arguments.
      * @param string $url The request URL.
      */
     $r = apply_filters('http_request_args', $r, $url);
     // The transports decrement this, store a copy of the original value for loop purposes.
     if (!isset($r['_redirection'])) {
         $r['_redirection'] = $r['redirection'];
     }
     /**
      * Filter whether to preempt an HTTP request's return value.
      *
      * Returning a non-false value from the filter will short-circuit the HTTP request and return
      * early with that value. A filter should return either:
      *
      *  - An array containing 'headers', 'body', 'response', 'cookies', and 'filename' elements
      *  - A WP_Error instance
      *  - boolean false (to avoid short-circuiting the response)
      *
      * Returning any other value may result in unexpected behaviour.
      *
      * @since 2.9.0
      *
      * @param false|array|WP_Error $preempt Whether to preempt an HTTP request's return value. Default false.
      * @param array               $r        HTTP request arguments.
      * @param string              $url      The request URL.
      */
     $pre = apply_filters('pre_http_request', false, $r, $url);
     if (false !== $pre) {
         return $pre;
     }
     if (function_exists('wp_kses_bad_protocol')) {
         if ($r['reject_unsafe_urls']) {
             $url = wp_http_validate_url($url);
         }
         if ($url) {
             $url = wp_kses_bad_protocol($url, array('http', 'https', 'ssl'));
         }
     }
     $arrURL = @parse_url($url);
     if (empty($url) || empty($arrURL['scheme'])) {
         return new WP_Error('http_request_failed', __('A valid URL was not provided.'));
     }
     if ($this->block_request($url)) {
         return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.'));
     }
     /*
      * Determine if this is a https call and pass that on to the transport functions
      * so that we can blacklist the transports that do not support ssl verification
      */
     $r['ssl'] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl';
     // Determine if this request is to OUR install of WordPress.
     $homeURL = parse_url(get_bloginfo('url'));
     $r['local'] = 'localhost' == $arrURL['host'] || isset($homeURL['host']) && $homeURL['host'] == $arrURL['host'];
     unset($homeURL);
     /*
      * If we are streaming to a file but no filename was given drop it in the WP temp dir
      * and pick its name using the basename of the $url.
      */
     if ($r['stream'] && empty($r['filename'])) {
         $r['filename'] = get_temp_dir() . wp_unique_filename(get_temp_dir(), basename($url));
     }
     /*
      * Force some settings if we are streaming to a file and check for existence and perms
      * of destination directory.
      */
开发者ID:mondi-webdigital,项目名称:prueba-wordpress,代码行数:67,代码来源:class-http.php


示例3: request


//.........这里部分代码省略.........
      *
      * @param array  $r   An array of HTTP request arguments.
      * @param string $url The request URL.
      */
     $r = apply_filters('http_request_args', $r, $url);
     // The transports decrement this, store a copy of the original value for loop purposes.
     if (!isset($r['_redirection'])) {
         $r['_redirection'] = $r['redirection'];
     }
     /**
      * Filters whether to preempt an HTTP request's return value.
      *
      * Returning a non-false value from the filter will short-circuit the HTTP request and return
      * early with that value. A filter should return either:
      *
      *  - An array containing 'headers', 'body', 'response', 'cookies', and 'filename' elements
      *  - A WP_Error instance
      *  - boolean false (to avoid short-circuiting the response)
      *
      * Returning any other value may result in unexpected behaviour.
      *
      * @since 2.9.0
      *
      * @param false|array|WP_Error $preempt Whether to preempt an HTTP request's return value. Default false.
      * @param array               $r        HTTP request arguments.
      * @param string              $url      The request URL.
      */
     $pre = apply_filters('pre_http_request', false, $r, $url);
     if (false !== $pre) {
         return $pre;
     }
     if (function_exists('wp_kses_bad_protocol')) {
         if ($r['reject_unsafe_urls']) {
             $url = wp_http_validate_url($url);
         }
         if ($url) {
             $url = wp_kses_bad_protocol($url, array('http', 'https', 'ssl'));
         }
     }
     $arrURL = @parse_url($url);
     if (empty($url) || empty($arrURL['scheme'])) {
         return new WP_Error('http_request_failed', __('A valid URL was not provided.'));
     }
     if ($this->block_request($url)) {
         return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.'));
     }
     // If we are streaming to a file but no filename was given drop it in the WP temp dir
     // and pick its name using the basename of the $url
     if ($r['stream']) {
         if (empty($r['filename'])) {
             $r['filename'] = get_temp_dir() . basename($url);
         }
         // Force some settings if we are streaming to a file and check for existence and perms of destination directory
         $r['blocking'] = true;
         if (!wp_is_writable(dirname($r['filename']))) {
             return new WP_Error('http_request_failed', __('Destination directory for file streaming does not exist or is not writable.'));
         }
     }
     if (is_null($r['headers'])) {
         $r['headers'] = array();
     }
     // WP allows passing in headers as a string, weirdly.
     if (!is_array($r['headers'])) {
         $processedHeaders = WP_Http::processHeaders($r['headers']);
         $r['headers'] = $processedHeaders['headers'];
     }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:67,代码来源:class-http.php


示例4: handle_callback_redirect

 /**
  * Handle redirecting the user after authorization
  *
  * @param string $verifier Verification code
  * @return null|WP_Error Null on success, error otherwise
  */
 public function handle_callback_redirect($verifier)
 {
     if (!empty($this->token['callback']) && $this->token['callback'] === 'oob') {
         return apply_filters('json_oauth1_handle_callback', null, $this->token);
     }
     if (empty($this->token['callback'])) {
         // No callback registered, display verification code to the user
         login_header(__('Access Token'));
         echo '<p>' . sprintf(__('Your verification token is <code>%s</code>'), $verifier) . '</p>';
         login_footer();
         return null;
     }
     $callback = $this->token['callback'];
     // Ensure the URL is safe to access
     // wp_http_validate_url is overly restrictive for desktop applications which might use
     // 127.0.0.1:xx for the callback. Add hook that allows localhost and check scheme/host of URL.
     $filtered_callback = parse_url($callback);
     $filtered_callback = $filtered_callback['scheme'] . '://' . $filtered_callback['host'];
     add_filter('http_request_host_is_external', array('WP_JSON_Authentication_OAuth1_Authorize', 'http_request_allow_external'));
     $filtered_callback = wp_http_validate_url($filtered_callback);
     remove_filter('http_request_host_is_external', array('WP_JSON_Authentication_OAuth1_Authorize', 'http_request_allow_external'));
     if (empty($filtered_callback)) {
         return new WP_Error('json_oauth1_invalid_callback', __('The callback URL is invalid'), array('status' => 400));
     }
     $args = array('oauth_token' => $this->token['key'], 'oauth_verifier' => $verifier, 'wp_scope' => '*');
     $args = apply_filters('json_oauth1_callback_args', $args, $token);
     $args = urlencode_deep($args);
     $callback = add_query_arg($args, $callback);
     wp_redirect($callback);
     return null;
 }
开发者ID:trevordevore,项目名称:OAuth1,代码行数:37,代码来源:class-wp-json-authentication-oauth1-authorize.php


示例5: handle_callback_redirect

 /**
  * Handle redirecting the user after authorization
  *
  * @param string $verifier Verification code
  * @return null|WP_Error Null on success, error otherwise
  */
 public function handle_callback_redirect($verifier)
 {
     if (!empty($this->token['callback']) && $this->token['callback'] === 'oob') {
         return apply_filters('json_oauth1_handle_callback', null, $this->token);
     }
     if (empty($this->token['callback'])) {
         // No callback registered, display verification code to the user
         login_header(__('Access Token'));
         echo '<p>' . sprintf(__('Your verification token is <code>%s</code>'), $verifier) . '</p>';
         login_footer();
         return null;
     }
     $callback = $this->token['callback'];
     // Ensure the URL is safe to access
     $callback = wp_http_validate_url($callback);
     if (empty($callback)) {
         return new WP_Error('json_oauth1_invalid_callback', __('The callback URL is invalid'), array('status' => 400));
     }
     $args = array('oauth_token' => $this->token['key'], 'oauth_verifier' => $verifier, 'wp_scope' => '*');
     $args = apply_filters('json_oauth1_callback_args', $args, $this->token);
     $args = urlencode_deep($args);
     $callback = add_query_arg($args, $callback);
     wp_redirect($callback);
     return null;
 }
开发者ID:duncanjbrown,项目名称:OAuth1,代码行数:31,代码来源:class-wp-json-authentication-oauth1-authorize.php


示例6: image_exist

 public function image_exist()
 {
     if (false == $this->image() || empty($this->img_src)) {
         return false;
     }
     $result = array();
     if (false == $this->is_local_attachment()) {
         if (false == wp_http_validate_url($this->img_src)) {
             return false;
         }
         $result['external'] = $this->img_src;
         return $result;
     }
     $this->img_src = preg_replace('/-\\d+x\\d+(?=\\.(jpg|jpeg|png|gif)$)/i', '', $this->img_src);
     $img_filename = str_replace($this->upurl . '/', '', $this->img_src);
     $img_path = $this->updir . '/' . $img_filename;
     if (file_exists($img_path) && false != getimagesize($img_path)) {
         if (5 > getimagesize($img_path)[0] || 5 > getimagesize($img_path)[1]) {
             $result['toosmall'] = array('filename' => $img_filename, 'path' => $img_path);
         } else {
             $result['exists'] = array('filename' => $img_filename, 'path' => $img_path, 'src' => $this->img_src);
         }
     } else {
         $result['noexists'] = array('src' => $this->img_src);
     }
     return $result;
 }
开发者ID:Jevuska,项目名称:extended-related-posts,代码行数:27,代码来源:class-extrp-thumbnail.php


示例7: queue_purge_url

 /**
  * PURGE a single URL
  *
  * @param string $url The specific URL to purge the cache for
  *
  * @return bool True on success
  */
 public function queue_purge_url($url)
 {
     $url = esc_url_raw($url);
     $url = wp_http_validate_url($url);
     if (false === $url) {
         return false;
     }
     $this->purge_urls[] = $url;
     return true;
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:17,代码来源:vip-cache-manager.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wp_id函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_http_supports函数代码示例发布时间: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