^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_blog_option()用法示例

get_blog_option( int $id,  string $option,  mixed $default = false )

Retrieve option value for a given blog id based on name of option.


描述

If the option does not exist or does not have a value, then the return value will be false. This is useful to check whether you need to install an option and is commonly used during installation of plugin options and to test whether upgrading is required.

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包

If the option was serialized then it will be unserialized when it is returned.


参数

$id

(int)
(Required)
A blog ID. Can be null to refer to the current blog.

$option

(string)
(Required)
Name of option to retrieve. Expected to not be SQL-escaped.

$default

(mixed)
(Optional)
Default value to return if the option does not exist.

Default value: false


返回值

(mixed) Value set for the option.


源代码

File: wp-includes/ms-blogs.php

function get_blog_option( $id, $option, $default = false ) {
	$id = (int) $id;

	if ( empty( $id ) )
		$id = get_current_blog_id();

	if ( get_current_blog_id() == $id )
		return get_option( $option, $default );

	switch_to_blog( $id );
	$value = get_option( $option, $default );
	restore_current_blog();

	/**
	 * Filters a blog option value.
	 *
	 * The dynamic portion of the hook name, `$option`, refers to the blog option name.
	 *
	 * @since 3.5.0
	 *
	 * @param string  $value The option value.
	 * @param int     $id    Blog ID.
	 */
	return apply_filters( "blog_option_{$option}", $value, $id );
}

更新日志

Version 描述
MU Introduced.

相关函数

Uses

  • wp-includes/load.php:
    get_current_blog_id()
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/option.php:
    get_option()
  • wp-includes/ms-blogs.php:
    switch_to_blog()
  • wp-includes/ms-blogs.php:
    restore_current_blog()
  • wp-includes/ms-blogs.php:
    blog_option_{$option}
  • Show 1 more use


Used By

  • wp-includes/rest-api.php:
    get_rest_url()
  • wp-includes/ms-functions.php:
    install_blog()

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Store Locator Plus

    This function is only available if WordPress has been installed and configured as a multisite install. Check function_exists() or use is_multisite() before calling get_blog_option().

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈