返回介绍

get_option()

发布于 2017-09-10 23:40:19 字数 31690 浏览 1115 评论 0 收藏 0

get_option( string $option,  mixed $default = false )

Retrieves an option value based on an option name.


description

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.

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

Any scalar values will be returned as strings. You may coerce the return type of a given option by registering an ‘option_$option’ filter callback.


参数

$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/option.php

function get_option( $option, $default = false ) {
	global $wpdb;

	$option = trim( $option );
	if ( empty( $option ) )
		return false;

	/**
	 * Filters the value of an existing option before it is retrieved.
	 *
	 * The dynamic portion of the hook name, `$option`, refers to the option name.
	 *
	 * Passing a truthy value to the filter will short-circuit retrieving
	 * the option value, returning the passed value instead.
	 *
	 * @since 1.5.0
	 * @since 4.4.0 The `$option` parameter was added.
	 *
	 * @param bool|mixed $pre_option Value to return instead of the option value.
	 *                               Default false to skip it.
	 * @param string     $option     Option name.
	 */
	$pre = apply_filters( "pre_option_{$option}", false, $option );
	if ( false !== $pre )
		return $pre;

	if ( defined( 'WP_SETUP_CONFIG' ) )
		return false;

	// Distinguish between `false` as a default, and not passing one.
	$passed_default = func_num_args() > 1;

	if ( ! wp_installing() ) {
		// prevent non-existent options from triggering multiple queries
		$notoptions = wp_cache_get( 'notoptions', 'options' );
		if ( isset( $notoptions[ $option ] ) ) {
			/**
			 * Filters the default value for an option.
			 *
			 * The dynamic portion of the hook name, `$option`, refers to the option name.
			 *
			 * @since 3.4.0
			 * @since 4.4.0 The `$option` parameter was added.
			 * @since 4.7.0 The `$passed_default` parameter was added to distinguish between a `false` value and the default parameter value.
			 *
			 * @param mixed  $default The default value to return if the option does not exist
			 *                        in the database.
			 * @param string $option  Option name.
			 * @param bool   $passed_default Was `get_option()` passed a default value?
			 */
			return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
		}

		$alloptions = wp_load_alloptions();

		if ( isset( $alloptions[$option] ) ) {
			$value = $alloptions[$option];
		} else {
			$value = wp_cache_get( $option, 'options' );

			if ( false === $value ) {
				$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );

				// Has to be get_row instead of get_var because of funkiness with 0, false, null values
				if ( is_object( $row ) ) {
					$value = $row->option_value;
					wp_cache_add( $option, $value, 'options' );
				} else { // option does not exist, so we must cache its non-existence
					if ( ! is_array( $notoptions ) ) {
 $notoptions = array();
					}
					$notoptions[$option] = true;
					wp_cache_set( 'notoptions', $notoptions, 'options' );

					/** This filter is documented in wp-includes/option.php */
					return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
				}
			}
		}
	} else {
		$suppress = $wpdb->suppress_errors();
		$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
		$wpdb->suppress_errors( $suppress );
		if ( is_object( $row ) ) {
			$value = $row->option_value;
		} else {
			/** This filter is documented in wp-includes/option.php */
			return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
		}
	}

	// If home is not set use siteurl.
	if ( 'home' == $option && '' == $value )
		return get_option( 'siteurl' );

	if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
		$value = untrailingslashit( $value );

	/**
	 * Filters the value of an existing option.
	 *
	 * The dynamic portion of the hook name, `$option`, refers to the option name.
	 *
	 * @since 1.5.0 As 'option_' . $setting
	 * @since 3.0.0
	 * @since 4.4.0 The `$option` parameter was added.
	 *
	 * @param mixed  $value  Value of the option. If stored serialized, it will be
	 *                       unserialized prior to being returned.
	 * @param string $option Option name.
	 */
	return apply_filters( "option_{$option}", maybe_unserialize( $value ), $option );
}

更新日志

Versiondescription
1.5.0Introduced.

More Information

A concise list of commonly-used options is below, but a more complete one can be found at the Option Reference.

  • 'admin_email' – E-mail address of blog administrator.
  • 'blogname' – Weblog title; set in General Options.
  • 'blogdescription' – Tagline for your blog; set in General Options.
  • 'blog_charset' – Character encoding for your blog; set in Reading Options.
  • 'date_format' – Default date format; set in General Options.
  • 'default_category' – Default post category; set in Writing Options.
  • 'home' – The blog’s home web address; set in General Options.
  • 'siteurl' – WordPress web address; set in General Options.
    Warning: This is not the same as get_bloginfo( 'url' ) (which will return the homepage url), but as get_bloginfo( 'wpurl' ).
  • 'template' – The current theme’s name; set in Presentation.
  • 'start_of_week' – Day of week calendar should start on; set in General Options.
  • 'upload_path' – Default upload location; set in Miscellaneous Options.
  • 'users_can_register' – Whether users can register; set in General Options.
  • 'posts_per_page' – Maximum number of posts to show on a page; set in Reading Options.
  • 'posts_per_rss' – Maximum number of most recent posts to show in the syndication feed; set in Reading Options.

There are many more options available, a lot of which depend on what plugins you have installed.


相关函数

Uses

  • wp-includes/load.php: wp_installing()
  • wp-includes/cache.php: wp_cache_get()
  • wp-includes/cache.php: wp_cache_add()
  • wp-includes/cache.php: wp_cache_set()
  • wp-includes/formatting.php: untrailingslashit()
  • wp-includes/functions.php: maybe_unserialize()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/option.php: wp_load_alloptions()
  • wp-includes/option.php: get_option()
  • wp-includes/option.php: pre_option_{$option}
  • wp-includes/option.php: default_option_{$option}
  • wp-includes/option.php: option_{$option}
  • wp-includes/wp-db.php: wpdb::get_row()
  • wp-includes/wp-db.php: wpdb::prepare()
  • wp-includes/wp-db.php: wpdb::suppress_errors()
  • Show 10 more uses Hide more uses

Used By

  • wp-admin/includes/class-wp-community-events.php: WP_Community_Events::format_event_data_time()
  • wp-includes/IXR/class-IXR-server.php: IXR_Server::output()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::update_stashed_theme_mod_settings()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::import_theme_starter_content()
  • wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::get_item_schema()
  • wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php: WP_REST_Settings_Controller::get_item()
  • wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php: WP_REST_Settings_Controller::update_item()
  • wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::prepare_item_for_response()
  • wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::get_items()
  • wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::get_item_schema()
  • wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::create_item_permissions_check()
  • wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::create_item()
  • wp-includes/class-wp-taxonomy.php: WP_Taxonomy::set_props()
  • wp-includes/class-wp-taxonomy.php: WP_Taxonomy::add_rewrite_rules()
  • wp-includes/script-loader.php: wp_localize_jquery_ui_datepicker()
  • wp-includes/class-wp-post-type.php: WP_Post_Type::add_rewrite_rules()
  • wp-includes/class-wp-post-type.php: WP_Post_Type::set_props()
  • wp-includes/class-wp-site.php: WP_Site::get_details()
  • wp-includes/link-template.php: wp_get_canonical_url()
  • wp-includes/rest-api/class-wp-rest-request.php: WP_REST_Request::from_url()
  • wp-includes/functions.php: _wp_upload_dir()
  • wp-admin/includes/class-wp-upgrader.php: WP_Upgrader::create_lock()
  • wp-includes/rest-api.php: get_rest_url()
  • wp-includes/embed.php: _oembed_rest_pre_serve_request()
  • wp-includes/embed.php: get_post_embed_url()
  • wp-includes/class-wp-customize-setting.php: WP_Customize_Setting::get_root_value()
  • wp-includes/taxonomy.php: wp_term_is_shared()
  • wp-includes/taxonomy.php: add_term_meta()
  • wp-includes/taxonomy.php: delete_term_meta()
  • wp-includes/taxonomy.php: get_term_meta()
  • wp-includes/taxonomy.php: update_term_meta()
  • wp-includes/taxonomy.php: update_termmeta_cache()
  • wp-includes/rest-api/class-wp-rest-server.php: WP_REST_Server::get_index()
  • wp-includes/rest-api/class-wp-rest-server.php: WP_REST_Server::serve_request()
  • wp-includes/comment.php: wp_handle_comment_submission()
  • wp-includes/comment.php: wp_new_comment_notify_postauthor()
  • wp-includes/option.php: get_network_option()
  • wp-admin/includes/class-wp-screen.php: WP_Screen::render_meta_boxes_preferences()
  • wp-admin/includes/ajax-actions.php: wp_ajax_delete_inactive_widgets()
  • wp-includes/customize/class-wp-customize-nav-menu-setting.php: WP_Customize_Nav_Menu_Setting::update()
  • wp-includes/customize/class-wp-customize-nav-menu-setting.php: WP_Customize_Nav_Menu_Setting::value()
  • wp-includes/taxonomy.php: _wp_batch_split_terms()
  • wp-includes/general-template.php: get_language_attributes()
  • wp-includes/general-template.php: get_site_icon_url()
  • wp-includes/formatting.php: format_for_editor()
  • wp-includes/comment.php: get_default_comment_status()
  • wp-includes/rewrite.php: wp_resolve_numeric_slug_conflicts()
  • wp-admin/includes/class-wp-ms-themes-list-table.php: WP_MS_Themes_List_Table::column_name()
  • wp-admin/includes/class-wp-site-icon.php: WP_Site_Icon::delete_attachment_data()
  • wp-admin/includes/class-wp-site-icon.php: WP_Site_Icon::get_post_metadata()
  • wp-admin/includes/class-wp-ms-sites-list-table.php: WP_MS_Sites_List_Table::column_blogname()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::unsanitized_post_values()
  • wp-includes/taxonomy.php: wp_get_split_terms()
  • wp-includes/link-template.php: get_avatar_data()
  • wp-admin/includes/class-wp-press-this.php: WP_Press_This::html()
  • wp-admin/includes/upgrade.php: wp_install_maybe_enable_pretty_permalinks()
  • wp-login.php: retrieve_password()
  • wp-trackback.php: trackback_response()
  • wp-admin/includes/network.php: allow_subdomain_install()
  • wp-admin/includes/network.php: get_clean_basedomain()
  • wp-admin/includes/network.php: network_step1()
  • wp-admin/includes/network.php: network_step2()
  • wp-admin/includes/class-wp-automatic-updater.php: WP_Automatic_Updater::send_email()
  • wp-admin/includes/export.php: export_wp()
  • wp-admin/includes/class-wp-plugins-list-table.php: WP_Plugins_List_Table::prepare_items()
  • wp-admin/includes/ms.php: update_option_new_admin_email()
  • wp-admin/includes/ms.php: send_confirmation_on_profile_email()
  • wp-admin/includes/ms.php: upload_space_setting()
  • wp-admin/includes/image-edit.php: wp_save_image()
  • wp-admin/includes/ms.php: wpmu_delete_blog()
  • wp-admin/includes/misc.php: update_recently_edited()
  • wp-admin/includes/schema.php: populate_network()
  • wp-admin/includes/image.php: wp_generate_attachment_metadata()
  • wp-admin/includes/dashboard.php: wp_welcome_panel()
  • wp-admin/includes/dashboard.php: wp_dashboard_rss_output()
  • wp-admin/includes/dashboard.php: wp_dashboard_cached_rss_widget()
  • wp-admin/includes/dashboard.php: wp_dashboard_rss_control()
  • wp-admin/includes/dashboard.php: wp_dashboard_right_now()
  • wp-admin/includes/upgrade.php: maybe_disable_link_manager()
  • wp-admin/includes/upgrade.php: wp_install_defaults()
  • wp-admin/includes/plugin.php: is_uninstallable_plugin()
  • wp-admin/includes/plugin.php: uninstall_plugin()
  • wp-admin/includes/plugin.php: is_plugin_active()
  • wp-admin/includes/plugin.php: activate_plugin()
  • wp-admin/includes/plugin.php: deactivate_plugins()
  • wp-admin/includes/plugin.php: validate_active_plugins()
  • wp-admin/includes/template.php: _wp_admin_html_begin()
  • wp-admin/includes/template.php: get_settings_errors()
  • wp-admin/includes/template.php: iframe_header()
  • wp-admin/includes/template.php: _post_states()
  • wp-admin/includes/template.php: _media_states()
  • wp-admin/includes/class-wp-themes-list-table.php: WP_Themes_List_Table::prepare_items()
  • wp-admin/includes/media.php: wp_media_insert_url_form()
  • wp-admin/includes/media.php: media_upload_max_image_resize()
  • wp-admin/includes/media.php: get_attachment_fields_to_edit()
  • wp-admin/includes/media.php: media_upload_form()
  • wp-admin/includes/post.php: get_sample_permalink_html()
  • wp-admin/includes/post.php: _fix_attachment_links()
  • wp-admin/includes/post.php: wp_edit_posts_query()
  • wp-admin/includes/post.php: get_default_post_to_edit()
  • wp-admin/includes/revision.php: wp_prepare_revisions_for_js()
  • wp-admin/includes/meta-boxes.php: page_attributes_meta_box()
  • wp-admin/includes/bookmark.php: wp_insert_link()
  • wp-admin/includes/bookmark.php: wp_set_link_cats()
  • wp-admin/includes/class-wp-comments-list-table.php: WP_Comments_List_Table::__construct()
  • wp-admin/includes/nav-menu.php: wp_nav_menu_update_menu_items()
  • wp-admin/includes/nav-menu.php: wp_nav_menu_item_post_type_meta_box()
  • wp-admin/includes/file.php: request_filesystem_credentials()
  • wp-admin/includes/file.php: get_home_path()
  • wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::__construct()
  • wp-admin/includes/options.php: options_reading_blog_charset()
  • wp-admin/custom-background.php: Custom_Background::wp_set_background_image()
  • wp-admin/custom-background.php: Custom_Background::handle_upload()
  • wp-includes/class-wp-roles.php: WP_Roles::_init()
  • wp-includes/class-wp-roles.php: WP_Roles::remove_role()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::register_controls()
  • wp-includes/capabilities.php: map_meta_cap()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::setup_theme()
  • wp-includes/cron.php: _get_cron_array()
  • wp-includes/category-template.php: wp_list_categories()
  • wp-includes/theme.php: check_theme_switched()
  • wp-includes/theme.php: set_theme_mod()
  • wp-includes/theme.php: remove_theme_mod()
  • wp-includes/theme.php: remove_theme_mods()
  • wp-includes/theme.php: get_uploaded_header_images()
  • wp-includes/theme.php: get_theme_root_uri()
  • wp-includes/theme.php: get_raw_theme_root()
  • wp-includes/theme.php: switch_theme()
  • wp-includes/theme.php: get_theme_mods()
  • wp-includes/theme.php: get_template()
  • wp-includes/theme.php: get_stylesheet()
  • wp-includes/l10n.php: get_locale()
  • wp-includes/formatting.php: esc_textarea()
  • wp-includes/formatting.php: sanitize_option()
  • wp-includes/deprecated.php: wp_htmledit_pre()
  • wp-includes/formatting.php: get_gmt_from_date()
  • wp-includes/formatting.php: get_date_from_gmt()
  • wp-includes/formatting.php: iso8601_to_datetime()
  • wp-includes/formatting.php: wp_trim_words()
  • wp-includes/deprecated.php: wp_richedit_pre()
  • wp-includes/formatting.php: convert_smilies()
  • wp-includes/formatting.php: balanceTags()
  • wp-includes/pluggable.php: get_avatar()
  • wp-includes/formatting.php: wp_check_invalid_utf8()
  • wp-includes/pluggable.php: wp_password_change_notification()
  • wp-includes/pluggable.php: wp_new_user_notification()
  • wp-includes/pluggable.php: wp_notify_postauthor()
  • wp-includes/pluggable.php: wp_notify_moderator()
  • wp-includes/pluggable.php: wp_set_auth_cookie()
  • wp-includes/general-template.php: noindex()
  • wp-includes/general-template.php: get_the_modified_date()
  • wp-includes/general-template.php: get_the_time()
  • wp-includes/general-template.php: get_the_modified_time()
  • wp-includes/general-template.php: wp_get_archives()
  • wp-includes/general-template.php: get_calendar()
  • wp-includes/general-template.php: get_the_date()
  • wp-includes/general-template.php: get_bloginfo()
  • wp-includes/general-template.php: wp_register()
  • wp-includes/deprecated.php: get_boundary_post_rel_link()
  • wp-includes/deprecated.php: get_parent_post_rel_link()
  • wp-includes/deprecated.php: get_current_theme()
  • wp-includes/deprecated.php: make_url_footnote()
  • wp-includes/deprecated.php: get_settings()
  • wp-includes/deprecated.php: get_links()
  • wp-includes/class-wp-theme.php: WP_Theme::get_allowed_on_site()
  • wp-includes/class-wp.php: WP::send_headers()
  • wp-includes/class-wp-query.php: WP_Query::is_front_page()
  • wp-includes/class-wp-query.php: WP_Query::get_queried_object()
  • wp-includes/class-wp-query.php: WP_Query::get_posts()
  • wp-includes/class-wp-query.php: WP_Query::parse_query()
  • wp-includes/load.php: wp_set_internal_encoding()
  • wp-includes/load.php: wp_get_active_and_valid_plugins()
  • wp-includes/class-wp-http-proxy.php: WP_HTTP_Proxy::send_through_proxy()
  • wp-includes/class-http.php: WP_Http::block_request()
  • wp-includes/functions.php: wp_timezone_override_offset()
  • wp-includes/functions.php: wp_send_json()
  • wp-includes/functions.php: smilies_init()
  • wp-includes/functions.php: do_robots()
  • wp-includes/functions.php: date_i18n()
  • wp-includes/functions.php: get_weekstartend()
  • wp-includes/functions.php: current_time()
  • wp-includes/widgets/class-wp-widget-rss.php: WP_Widget_RSS::widget()
  • wp-includes/widgets/class-wp-widget-recent-comments.php: WP_Widget_Recent_Comments::widget()
  • wp-includes/widgets.php: wp_widget_rss_output()
  • wp-includes/widgets.php: wp_widgets_init()
  • wp-includes/taxonomy.php: wp_unique_term_slug()
  • wp-includes/taxonomy.php: wp_delete_term()
  • wp-includes/default-constants.php: wp_cookie_constants()
  • wp-includes/default-constants.php: wp_ssl_constants()
  • wp-includes/taxonomy.php: create_initial_taxonomies()
  • wp-includes/link-template.php: wp_get_shortlink()
  • wp-includes/default-constants.php: wp_plugin_directory_constants()
  • wp-includes/link-template.php: get_comments_pagenum_link()
  • wp-includes/link-template.php: get_home_url()
  • wp-includes/link-template.php: get_site_url()
  • wp-includes/link-template.php: get_adjacent_post_link()
  • wp-includes/link-template.php: get_adjacent_post_rel_link()
  • wp-includes/link-template.php: get_post_type_archive_link()
  • wp-includes/link-template.php: get_post_type_archive_feed_link()
  • wp-includes/link-template.php: get_term_feed_link()
  • wp-includes/link-template.php: get_post_comments_feed_link()
  • wp-includes/link-template.php: get_author_feed_link()
  • wp-includes/link-template.php: get_permalink()
  • wp-includes/link-template.php: get_page_link()
  • wp-includes/link-template.php: get_attachment_link()
  • wp-includes/class-wp-ajax-response.php: WP_Ajax_Response::send()
  • wp-includes/http.php: wp_http_validate_url()
  • wp-includes/update.php: wp_update_plugins()
  • wp-includes/update.php: wp_update_themes()
  • wp-includes/admin-bar.php: wp_admin_bar_edit_menu()
  • wp-includes/plugin.php: register_uninstall_hook()
  • wp-includes/feed.php: get_the_category_rss()
  • wp-includes/feed.php: fetch_feed()
  • wp-includes/option.php: get_transient()
  • wp-includes/option.php: set_transient()
  • wp-includes/option.php: update_option()
  • wp-includes/option.php: add_option()
  • wp-includes/option.php: get_option()
  • wp-includes/option.php: form_option()
  • wp-includes/user.php: wp_update_user()
  • wp-includes/user.php: register_new_user()
  • wp-includes/user.php: wp_insert_user()
  • wp-includes/user.php: get_blogs_of_user()
  • wp-includes/bookmark-template.php: _walk_bookmarks()
  • wp-includes/nav-menu-template.php: _wp_menu_item_classes_by_context()
  • wp-includes/class-walker-page.php: Walker_Page::start_el()
  • wp-includes/post-template.php: _wp_link_page()
  • wp-includes/post-template.php: wp_list_pages()
  • wp-includes/post-template.php: wp_page_menu()
  • wp-includes/media.php: wp_enqueue_media()
  • wp-includes/media.php: image_constrain_size_for_editor()
  • wp-includes/post.php: _publish_post_hook()
  • wp-includes/post.php: wp_unique_post_slug()
  • wp-includes/post.php: wp_set_post_categories()
  • wp-includes/post.php: wp_insert_post()
  • wp-includes/post.php: _reset_front_page_settings_for_post()
  • wp-includes/post.php: is_sticky()
  • wp-includes/post.php: stick_post()
  • wp-includes/post.php: unstick_post()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::init()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::set_category_base()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::set_tag_base()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::wp_rewrite_rules()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::generate_rewrite_rules()
  • wp-includes/rewrite.php: url_to_postid()
  • wp-includes/canonical.php: redirect_canonical()
  • wp-includes/revision.php: _wp_upgrade_revisions_of_post()
  • wp-includes/ms-functions.php: get_space_allowed()
  • wp-includes/ms-functions.php: maybe_add_existing_user_to_blog()
  • wp-includes/ms-functions.php: wpmu_welcome_user_notification()
  • wp-includes/ms-functions.php: global_terms()
  • wp-includes/ms-functions.php: newblog_notify_siteadmin()
  • wp-includes/ms-functions.php: wpmu_welcome_notification()
  • wp-includes/ms-functions.php: wpmu_signup_blog_notification()
  • wp-includes/ms-functions.php: wpmu_signup_user_notification()
  • wp-includes/ms-blogs.php: get_blog_option()
  • wp-includes/ms-blogs.php: get_blog_details()
  • wp-includes/nav-menu.php: _wp_auto_add_pages_to_menu()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::pingback_ping()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::_getOptions()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::blogger_getUsersBlogs()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::wp_newComment()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::wp_getUsersBlogs()
  • wp-includes/ms-default-constants.php: ms_cookie_constants()
  • wp-includes/class-wp-widget.php: WP_Widget::get_settings()
  • wp-includes/widgets.php: is_dynamic_sidebar()
  • wp-includes/widgets.php: wp_get_sidebars_widgets()
  • wp-includes/widgets.php: wp_convert_widget_settings()
  • wp-includes/comment-template.php: get_post_reply_link()
  • wp-includes/comment-template.php: wp_list_comments()
  • wp-includes/comment-template.php: comment_form()
  • wp-includes/comment-template.php: get_trackback_url()
  • wp-includes/comment-template.php: comments_template()
  • wp-includes/comment-template.php: get_comment_reply_link()
  • wp-includes/comment-template.php: get_comment_link()
  • wp-includes/comment-template.php: get_comment_time()
  • wp-includes/comment-template.php: get_comment_date()
  • wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::preview_sidebars_widgets()
  • wp-includes/comment.php: privacy_ping_filter()
  • wp-includes/comment.php: trackback()
  • wp-includes/comment.php: weblog_ping()
  • wp-includes/comment.php: _close_comments_for_old_posts()
  • wp-includes/comment.php: _close_comments_for_old_post()
  • wp-includes/comment.php: generic_ping()
  • wp-includes/comment.php: get_comment_pages_count()
  • wp-includes/comment.php: get_page_of_comment()
  • wp-includes/comment.php: wp_blacklist_check()
  • wp-includes/comment.php: check_comment()
  • Show 283 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: 2You must log in to vote on the helpfulness of this note Contributed by Codex

    Show Blog Title
    Displays your blog’s title in a <h1> tag.

    
    <h1><?php echo get_option( 'blogname' ); ?></h1>
    
  2. Show Character Set
    Displays the character set your blog is using (ex: UTF-8)

    
    <p><?php echo esc_html( sprintf( __( 'Character set: %s', 'textdomain' ), get_option( 'blog_charset' ) ) ); ?></p>
    

    Retrieve Administrator E-mail
    Retrieve the e-mail of the blog administrator, storing it in a variable.

    
    <?php $admin_email = get_option( 'admin_email' ); ?>
    

    Handling of non-existing options

    
    $no_exists_value = get_option( 'no_exists_value' );
    var_dump( $no_exists_value ); /* outputs false */
    
    $no_exists_value = get_option( 'no_exists_value', 'default_value' );
    var_dump( $no_exists_value ); /* outputs 'default_value' */
    

    If you want to get a network-wide option, use the get_site_option function instead. https://codex.wordpress.org/Function_Reference/get_site_option

    Your note is awaiting moderation.

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

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

发布评论

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