返回介绍

site_url()

发布于 2017-09-11 10:27:52 字数 4146 浏览 951 评论 0 收藏 0

site_url( string $path = '',  string $scheme = null )

Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.


description

Returns the ‘site_url’ option with the appropriate protocol, ‘https’ if is_ssl() and ‘http’ otherwise. If $scheme is ‘http’ or ‘https’, is_ssl() is overridden.


参数

$path

(string) (Optional) Path relative to the site URL.

Default value: ''

$scheme

(string) (Optional) Scheme to give the site URL context. See set_url_scheme().

Default value: null


返回值

(string) Site URL link with optional path appended.


源代码

File: wp-includes/link-template.php

function site_url( $path = '', $scheme = null ) {
	return get_site_url( null, $path, $scheme );
}

更新日志

Versiondescription
3.0.0Introduced.

相关函数

Uses

  • wp-includes/link-template.php: get_site_url()

Used By

  • wp-admin/includes/file.php: wp_print_request_filesystem_credentials_modal()
  • wp-includes/cron.php: spawn_cron()
  • wp-includes/theme.php: get_theme_root_uri()
  • wp-includes/formatting.php: translate_smiley()
  • wp-includes/general-template.php: rsd_link()
  • wp-includes/general-template.php: get_bloginfo()
  • wp-includes/general-template.php: wp_logout_url()
  • wp-includes/general-template.php: wp_login_url()
  • wp-includes/general-template.php: wp_registration_url()
  • wp-includes/general-template.php: wp_login_form()
  • wp-includes/functions.php: do_robots()
  • wp-includes/widgets/class-wp-widget-rss.php: WP_Widget_RSS::widget()
  • wp-includes/link-template.php: includes_url()
  • wp-includes/link-template.php: network_site_url()
  • wp-includes/post-template.php: get_the_password_form()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::mod_rewrite_rules()
  • wp-includes/canonical.php: wp_redirect_admin_locations()
  • wp-includes/ms-functions.php: newblog_notify_siteadmin()
  • wp-includes/ms-functions.php: wpmu_signup_user_notification()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::blogger_getUsersBlogs()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::wp_getUsersBlogs()
  • wp-includes/comment-template.php: comment_form()
  • wp-includes/script-loader.php: wp_default_styles()
  • wp-includes/script-loader.php: wp_default_scripts()
  • Show 19 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

    Examples

    
    $url = site_url();
    echo $url;
    

    Output: http://www.example.com or http://www.example.com/wordpress

    (Note the lack of a trailing slash)

    
    $url = site_url( '/secrets/', 'https' );
    echo $url;
    

    Output: https://www.example.com/secrets/ or https://www.example.com/wordpress/secrets/

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

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

发布评论

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