返回介绍

esc_url_raw()

发布于 2017-09-10 22:29:31 字数 5052 浏览 856 评论 0 收藏 0

esc_url_raw( string $url,  array $protocols = null )

Performs esc_url() for database usage.


description


参数

$url

(string) (Required) The URL to be cleaned.

$protocols

(array) (Optional) An array of acceptable protocols.

Default value: null


返回值

(string) The cleaned URL.


源代码

File: wp-includes/formatting.php

function esc_url_raw( $url, $protocols = null ) {
	return esc_url( $url, $protocols, 'db' );
}

更新日志

Versiondescription
2.8.0Introduced.

相关函数

Uses

  • wp-includes/formatting.php: esc_url()

Used By

  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::_sanitize_external_header_video()
  • wp-includes/rest-api.php: rest_sanitize_value_from_schema()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::_sanitize_background_setting()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::_validate_external_header_video()
  • wp-includes/theme.php: get_header_video_url()
  • wp-includes/rest-api.php: rest_send_cors_headers()
  • wp-includes/rest-api.php: rest_output_link_header()
  • wp-includes/embed.php: get_post_embed_url()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::set_return_url()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::customize_pane_settings()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::set_preview_url()
  • wp-includes/rest-api/class-wp-rest-server.php: WP_REST_Server::serve_request()
  • wp-includes/customize/class-wp-customize-nav-menu-item-setting.php: WP_Customize_Nav_Menu_Item_Setting::sanitize()
  • wp-includes/theme.php: get_editor_stylesheets()
  • wp-admin/includes/theme.php: wp_prepare_themes_for_js()
  • wp-admin/includes/export.php: export_wp()
  • wp-admin/includes/user.php: edit_user()
  • wp-admin/includes/media.php: wp_media_upload_handler()
  • wp-admin/includes/ajax-actions.php: wp_ajax_send_link_to_editor()
  • wp-admin/includes/post.php: edit_post()
  • wp-admin/includes/ajax-actions.php: _wp_ajax_delete_comment_response()
  • wp-admin/custom-header.php: Custom_Image_Header::set_header_image()
  • wp-admin/custom-background.php: Custom_Background::wp_set_background_image()
  • wp-admin/custom-background.php: Custom_Background::handle_upload()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::customize_preview_settings()
  • wp-includes/theme.php: _custom_background_cb()
  • wp-includes/theme.php: get_header_image()
  • wp-includes/theme.php: get_uploaded_header_images()
  • wp-includes/formatting.php: get_url_in_content()
  • wp-includes/formatting.php: sanitize_option()
  • wp-includes/deprecated.php: sanitize_url()
  • wp-includes/class-wp-theme.php: WP_Theme::sanitize_header()
  • wp-includes/widgets.php: wp_widget_rss_process()
  • wp-includes/link-template.php: get_pagenum_link()
  • wp-includes/ms-deprecated.php: get_blogaddress_by_domain()
  • wp-includes/nav-menu.php: wp_update_nav_menu_item()
  • wp-includes/script-loader.php: wp_default_scripts()
  • Show 32 more used by Hide more used by

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 1You must log in to vote on the helpfulness of this note Contributed by Codex

    Right and Wrong usage

    
    <!-- Right -->
    $url = 'http://wordpress.org';
    $response = wp_remote_get( esc_url_raw( $url ) ); // no need to escape entities
    
    if ( ! is_wp_error( $response ) ) {
    	echo wp_remote_retrieve_body( $response );
    }
    
    
    <!-- Wrong! Use esc_url instead! -->
    <img src="<?php echo esc_url_raw( $url ); ?>" />
    <a href="<?php echo esc_url_raw( $url ); ?>">WordPress</a>
    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文