get_option( string $option, mixed $default = false )
Retrieves an option value based on an option name.
Contents
Description #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.
Parameters #Parameters
- $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
Return #Return
(mixed) Value set for the option.
Source #Source
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. * @since 4.9.0 The `$default` parameter was added. * * @param bool|mixed $pre_option The value to return instead of the option value. This differs from * `$default`, which is used as the fallback value in the event the option * doesn't exist elsewhere in get_option(). Default false (to skip past the * short-circuit). * @param string $option Option name. * @param mixed $default The fallback value to return if the option does not exist. * Default is false. */ $pre = apply_filters( "pre_option_{$option}", false, $option, $default ); 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 ); }
Expand full source code Collapse full source code View on Trac
Changelog #Changelog
Version | Description |
---|---|
1.5.0 | Introduced. |
More Information #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 asget_bloginfo( 'url' )
(which will return the homepage url), but asget_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.
Related #Related
Uses #Uses
Uses | Description |
---|---|
wp-includes/load.php: wp_installing() |
Check or set whether WordPress is in “installation” mode. |
wp-includes/cache.php: wp_cache_get() |
Retrieves the cache contents from the cache by key and group. |
wp-includes/cache.php: wp_cache_add() |
Adds data to the cache, if the cache key doesn’t already exist. |
wp-includes/cache.php: wp_cache_set() |
Saves the data to the cache. |
wp-includes/formatting.php: untrailingslashit() |
Removes trailing forward slashes and backslashes if they exist. |
wp-includes/functions.php: maybe_unserialize() |
Unserialize value only if it was serialized. |
wp-includes/plugin.php: apply_filters() |
Call the functions added to a filter hook. |
wp-includes/option.php: wp_load_alloptions() |
Loads and caches all autoloaded options, if available or all options. |
wp-includes/option.php: get_option() |
Retrieves an option value based on an option name. |
wp-includes/option.php: pre_option_{$option} |
Filters the value of an existing option before it is retrieved. |
wp-includes/option.php: default_option_{$option} |
Filters the default value for an option. |
wp-includes/option.php: option_{$option} |
Filters the value of an existing option. |
wp-includes/wp-db.php: wpdb::get_row() |
Retrieve one row from the database. |
wp-includes/wp-db.php: wpdb::suppress_errors() |
Whether to suppress database errors. |
wp-includes/wp-db.php: wpdb::prepare() |
Prepares a SQL query for safe execution. Uses sprintf()-like syntax. |
Used By #Used By
Used By | Description |
---|---|
wp-admin/includes/schema.php: populate_network_meta() |
Creates WordPress network meta and sets the default values. |
wp-includes/blocks/latest-comments.php: render_block_core_latest_comments() |
Renders the |
wp-includes/taxonomy.php: wp_check_term_meta_support_prefilter() |
Aborts calls to term meta if it is not supported. |
wp-includes/script-loader.php: wp_default_packages_vendor() |
Registers all the WordPress vendor scripts that are in the standardized |
wp-includes/script-loader.php: wp_default_packages_inline_scripts() |
Adds inline scripts required for the WordPress JavaScript packages. |
wp-admin/includes/post.php: use_block_editor_for_post() |
Return whether the post can be edited in the block editor. |
wp-includes/user.php: _wp_privacy_send_request_confirmation_notification() |
Notify the site administrator via email when a request is confirmed. |
wp-includes/user.php: _wp_privacy_send_erasure_fulfillment_notification() |
Notify the user when their erasure request is fulfilled. |
wp-includes/user.php: wp_send_user_request() |
Send a confirmation request email to confirm an action. |
wp-includes/link-template.php: get_the_privacy_policy_link() |
Returns the privacy policy link with formatting, when applicable. |
wp-includes/link-template.php: get_privacy_policy_url() |
Retrieves the URL to the privacy policy page. |
wp-admin/includes/misc.php: WP_Privacy_Policy_Content::get_suggested_policy_text() |
Check for updated, added or removed privacy policy information from plugins. |
wp-admin/includes/misc.php: WP_Privacy_Policy_Content::notice() |
Add a notice with a link to the guide when editing the privacy policy page. |
wp-admin/includes/misc.php: WP_Privacy_Policy_Content::text_change_check() |
Quick check if any privacy info has changed. |
wp-admin/includes/misc.php: WP_Privacy_Policy_Content::_policy_page_updated() |
Update the cached policy info when the policy page is updated. |
wp-admin/includes/file.php: wp_privacy_send_personal_data_export_email() |
Send an email to the user with a link to the personal data export file |
wp-admin/includes/user.php: WP_Privacy_Requests_Table::get_timestamp_as_date() |
Convert timestamp for display. |
wp-includes/class-wp-roles.php: WP_Roles::get_roles_data() |
Gets the available roles data. |
wp-includes/nav-menu.php: _wp_menus_changed() |
Handle menu config after theme change. |
wp-includes/functions.php: wp_site_admin_email_change_notification() |
Send an email to the old site admin email address when the site admin email address changes. |
wp-includes/customize/class-wp-customize-date-time-control.php: WP_Customize_Date_Time_Control::content_template() |
Renders a JS template for the content of date time control. |
wp-includes/customize/class-wp-customize-date-time-control.php: WP_Customize_Date_Time_Control::get_timezone_info() |
Get timezone info. |
wp-admin/includes/file.php: wp_edit_theme_plugin_file() |
Attempt to edit a file for a theme or plugin. |
wp-admin/includes/class-wp-community-events.php: WP_Community_Events::format_event_data_time() |
Adds formatted date and time items for each event in an API response. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::update_stashed_theme_mod_settings() |
Update stashed theme mod settings. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::import_theme_starter_content() |
Import theme starter content into the customized state. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::get_item_schema() |
Retrieves the user’s schema, conforming to JSON Schema. |
wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php: WP_REST_Settings_Controller::get_item() |
Retrieves the settings. |
wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php: WP_REST_Settings_Controller::update_item() |
Updates settings for the settings object. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::prepare_item_for_response() |
Prepares a single post output for response. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::get_items() |
Retrieves a collection of posts. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::get_item_schema() |
Retrieves the comment’s schema, conforming to JSON Schema. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::create_item_permissions_check() |
Checks if a given request has access to create a comment. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::create_item() |
Creates a comment. |
wp-includes/class-wp-taxonomy.php: WP_Taxonomy::set_props() |
Sets taxonomy properties. |
wp-includes/class-wp-taxonomy.php: WP_Taxonomy::add_rewrite_rules() |
Adds the necessary rewrite rules for the taxonomy. |
wp-includes/script-loader.php: wp_localize_jquery_ui_datepicker() |
Localizes the jQuery UI datepicker. |
wp-includes/class-wp-post-type.php: WP_Post_Type::add_rewrite_rules() |
Adds the necessary rewrite rules for the post type. |
wp-includes/class-wp-post-type.php: WP_Post_Type::set_props() |
Sets post type properties. |
wp-includes/class-wp-site.php: WP_Site::get_details() |
Retrieves the details for this site. |
wp-includes/link-template.php: wp_get_canonical_url() |
Returns the canonical URL for a post. |
wp-includes/rest-api/class-wp-rest-request.php: WP_REST_Request::from_url() |
Retrieves a WP_REST_Request object from a full URL. |
wp-includes/functions.php: _wp_upload_dir() |
A non-filtered, non-cached version of wp_upload_dir() that doesn’t check the path. |
wp-admin/includes/class-wp-upgrader.php: WP_Upgrader::create_lock() |
Creates a lock using WordPress options. |
wp-includes/rest-api.php: get_rest_url() |
Retrieves the URL to a REST endpoint on a site. |
wp-includes/embed.php: _oembed_rest_pre_serve_request() |
Hooks into the REST API output to print XML instead of JSON. |
wp-includes/embed.php: get_post_embed_url() |
Retrieves the URL to embed a specific post in an iframe. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::customize_pane_settings() |
Print JavaScript settings for parent window. |
wp-includes/class-wp-customize-setting.php: WP_Customize_Setting::get_root_value() |
Get the root value for a setting, especially for multidimensional ones. |
wp-includes/taxonomy.php: wp_term_is_shared() |
Determine whether a term is shared between multiple taxonomies. |
wp-includes/rest-api/class-wp-rest-server.php: WP_REST_Server::get_index() |
Retrieves the site index. |
wp-includes/rest-api/class-wp-rest-server.php: WP_REST_Server::serve_request() |
Handles serving an API request. |
wp-includes/comment.php: wp_handle_comment_submission() |
Handles the submission of a comment, usually posted to wp-comments-post.php via a comment form. |
wp-includes/comment.php: wp_new_comment_notify_postauthor() |
Send a notification of a new comment to the post author. |
wp-includes/option.php: get_network_option() |
Retrieve a network’s option value based on the option name. |
wp-admin/includes/class-wp-screen.php: WP_Screen::render_meta_boxes_preferences() |
Render the meta boxes preferences. |
wp-admin/includes/ajax-actions.php: wp_ajax_delete_inactive_widgets() |
Ajax handler for removing inactive widgets. |
wp-includes/customize/class-wp-customize-nav-menu-setting.php: WP_Customize_Nav_Menu_Setting::update() |
Create/update the nav_menu term for this setting. |
wp-includes/customize/class-wp-customize-nav-menu-setting.php: WP_Customize_Nav_Menu_Setting::value() |
Get the instance data for a given widget setting. |
wp-includes/taxonomy.php: _wp_batch_split_terms() |
Splits a batch of shared taxonomy terms. |
wp-includes/general-template.php: get_language_attributes() |
Gets the language attributes for the html tag. |
wp-includes/general-template.php: get_site_icon_url() |
Returns the Site Icon URL. |
wp-includes/formatting.php: format_for_editor() |
Formats text for the editor. |
wp-includes/comment.php: get_default_comment_status() |
Gets the default comment status for a post type. |
wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::customize_register() |
Add the customizer settings and controls. |
wp-includes/rewrite.php: wp_resolve_numeric_slug_conflicts() |
Resolve numeric slugs that collide with date permalinks. |
wp-admin/includes/class-wp-ms-themes-list-table.php: WP_MS_Themes_List_Table::column_name() |
Handles the name column output. |
wp-admin/includes/class-wp-site-icon.php: WP_Site_Icon::delete_attachment_data() |
Deletes the Site Icon when the image file is deleted. |
wp-admin/includes/class-wp-site-icon.php: WP_Site_Icon::get_post_metadata() |
Adds custom image sizes when meta data for an image is requested, that happens to be used as Site Icon. |
wp-admin/includes/class-wp-ms-sites-list-table.php: WP_MS_Sites_List_Table::column_blogname() |
Handles the site name column output. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::unsanitized_post_values() |
Get dirty pre-sanitized setting values in the current customized state. |
wp-includes/taxonomy.php: wp_get_split_terms() |
Get data about terms that previously shared a single term_id, but have since been split. |
wp-includes/link-template.php: get_avatar_data() |
Retrieves default data about the avatar. |
wp-admin/includes/upgrade.php: wp_install_maybe_enable_pretty_permalinks() |
Maybe enable pretty permalinks on installation. |
wp-login.php: retrieve_password() |
Handles sending password retrieval email to user. |
wp-trackback.php: trackback_response() |
Response to a trackback. |
wp-admin/includes/network.php: allow_subdomain_install() |
Allow subdomain installation |
wp-admin/includes/network.php: get_clean_basedomain() |
Get base domain of network. |
wp-admin/includes/network.php: network_step1() |
Prints step 1 for Network installation process. |
wp-admin/includes/network.php: network_step2() |
Prints step 2 for Network installation process. |
wp-admin/includes/class-wp-automatic-updater.php: WP_Automatic_Updater::send_email() |
Sends an email upon the completion or failure of a background core update. |
wp-admin/includes/class-wp-plugins-list-table.php: WP_Plugins_List_Table::prepare_items() | |
wp-admin/includes/export.php: export_wp() |
Generates the WXR export file for download. |
wp-admin/includes/ms.php: upload_space_setting() |
Displays the site upload space quota setting form on the Edit Site Settings screen. |
wp-admin/includes/misc.php: update_option_new_admin_email() |
Send a confirmation request email when a change of site admin email address is attempted. |
wp-includes/user.php: send_confirmation_on_profile_email() |
Send a confirmation request email when a change of user email address is attempted. |
wp-admin/includes/ms.php: wpmu_delete_blog() |
Delete a site. |
wp-admin/includes/image-edit.php: wp_save_image() |
Saves image to post along with enqueued changes in $_REQUEST[‘history’] |
wp-admin/includes/misc.php: update_recently_edited() |
Update the “recently-edited” file for the plugin or theme editor. |
wp-admin/includes/image.php: wp_generate_attachment_metadata() |
Generate post thumbnail attachment meta data. |
wp-admin/includes/dashboard.php: wp_welcome_panel() |
Displays a welcome panel to introduce users to WordPress. |
wp-admin/includes/dashboard.php: wp_dashboard_rss_output() |
Display generic dashboard RSS widget feed. |
wp-admin/includes/dashboard.php: wp_dashboard_cached_rss_widget() |
Checks to see if all of the feed url in $check_urls are cached. |
wp-admin/includes/dashboard.php: wp_dashboard_rss_control() |
The RSS dashboard widget control. |
wp-admin/includes/dashboard.php: wp_dashboard_right_now() |
Dashboard widget that displays some basic stats about the site. |
wp-admin/includes/upgrade.php: maybe_disable_link_manager() |
Disables the Link Manager on upgrade if, at the time of upgrade, no links exist in the DB. |
wp-admin/includes/upgrade.php: wp_install_defaults() |
Creates the initial content for a newly-installed site. |
wp-admin/includes/plugin.php: is_uninstallable_plugin() |
Whether the plugin can be uninstalled. |
wp-admin/includes/plugin.php: uninstall_plugin() |
Uninstall a single plugin. |
wp-admin/includes/plugin.php: is_plugin_active() |
Determines whether a plugin is active. |
wp-admin/includes/plugin.php: activate_plugin() |
Attempts activation of plugin in a “sandbox” and redirects on success. |
wp-admin/includes/plugin.php: deactivate_plugins() |
Deactivate a single plugin or multiple plugins. |
wp-admin/includes/plugin.php: validate_active_plugins() |
Validate active plugins |
wp-admin/includes/template.php: _wp_admin_html_begin() | |
wp-admin/includes/template.php: get_settings_errors() |
Fetch settings errors registered by add_settings_error(). |
wp-admin/includes/template.php: iframe_header() |
Generic Iframe header for use with Thickbox |
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() |
Creates the form for external url |
wp-admin/includes/media.php: media_upload_max_image_resize() |
Displays the checkbox to scale images. |
wp-admin/includes/media.php: get_attachment_fields_to_edit() |
Retrieves the attachment fields to edit form fields. |
wp-admin/includes/media.php: media_upload_form() |
Outputs the legacy media upload form. |
wp-admin/includes/post.php: get_sample_permalink_html() |
Returns the HTML of the sample permalink slug editor. |
wp-admin/includes/post.php: _fix_attachment_links() |
Replace hrefs of attachment anchors with up-to-date permalinks. |
wp-admin/includes/post.php: wp_edit_posts_query() |
Run the wp query to fetch the posts for listing on the edit posts page |
wp-admin/includes/post.php: get_default_post_to_edit() |
Default post information to use when populating the “Write Post” form. |
wp-admin/includes/revision.php: wp_prepare_revisions_for_js() |
Prepare revisions for JavaScript. |
wp-admin/includes/meta-boxes.php: page_attributes_meta_box() |
Display page attributes form fields. |
wp-admin/includes/bookmark.php: wp_insert_link() |
Inserts/updates links into/in the database. |
wp-admin/includes/bookmark.php: wp_set_link_cats() |
Update link with the specified link categories. |
wp-admin/includes/class-wp-comments-list-table.php: WP_Comments_List_Table::__construct() |
Constructor. |
wp-admin/includes/nav-menu.php: wp_nav_menu_update_menu_items() |
Saves nav menu items |
wp-admin/includes/nav-menu.php: wp_nav_menu_item_post_type_meta_box() |
Displays a meta box for a post type menu item. |
wp-admin/includes/file.php: request_filesystem_credentials() |
Displays a form to the user to request for their FTP/SSH details in order to connect to the filesystem. |
wp-admin/includes/file.php: get_home_path() |
Get the absolute filesystem path to the root of the WordPress installation |
wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::__construct() |
Constructor. |
wp-admin/includes/options.php: options_reading_blog_charset() |
Render the site charset setting. |
wp-admin/custom-background.php: Custom_Background::wp_set_background_image() | |
wp-admin/custom-background.php: Custom_Background::handle_upload() |
Handle an Image upload for the background image. |
wp-includes/class-wp-roles.php: WP_Roles::remove_role() |
Remove role by name. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::register_controls() |
Register some default controls. |
wp-includes/capabilities.php: map_meta_cap() |
Map meta capabilities to primitive capabilities. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::setup_theme() |
Start preview and customize theme. |
wp-includes/cron.php: _get_cron_array() |
Retrieve cron info array option. |
wp-includes/category-template.php: wp_list_categories() |
Display or retrieve the HTML list of categories. |
wp-includes/theme.php: check_theme_switched() |
Checks if a theme has been changed and runs ‘after_switch_theme’ hook on the next WP load. |
wp-includes/theme.php: set_theme_mod() |
Update theme modification value for the current theme. |
wp-includes/theme.php: remove_theme_mod() |
Remove theme modification name from current theme list. |
wp-includes/theme.php: remove_theme_mods() |
Remove theme modifications option for current theme. |
wp-includes/theme.php: get_uploaded_header_images() |
Get the header images uploaded for the current theme. |
wp-includes/theme.php: get_theme_root_uri() |
Retrieve URI for themes directory. |
wp-includes/theme.php: get_raw_theme_root() |
Get the raw theme root relative to the content directory with no filters applied. |
wp-includes/theme.php: switch_theme() |
Switches the theme. |
wp-includes/theme.php: get_theme_mods() |
Retrieve all theme modifications. |
wp-includes/theme.php: get_template() |
Retrieve name of the current theme. |
wp-includes/theme.php: get_stylesheet() |
Retrieve name of the current stylesheet. |
wp-includes/l10n.php: get_locale() |
Retrieves the current locale. |
wp-includes/formatting.php: esc_textarea() |
Escaping for textarea values. |
wp-includes/formatting.php: sanitize_option() |
Sanitises various option values based on the nature of the option. |
wp-includes/deprecated.php: wp_htmledit_pre() |
Formats text for the HTML editor. |
wp-includes/deprecated.php: wp_richedit_pre() |
Formats text for the rich text editor. |
wp-includes/formatting.php: get_gmt_from_date() |
Returns a date in the GMT equivalent. |
wp-includes/formatting.php: get_date_from_gmt() |
Converts a GMT date into the correct format for the blog. |
wp-includes/formatting.php: iso8601_to_datetime() |
Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]. |
wp-includes/formatting.php: wp_trim_words() |
Trims text to a certain number of words. |
wp-includes/formatting.php: convert_smilies() |
Convert text equivalent of smilies to images. |
wp-includes/formatting.php: balanceTags() |
Balances tags if forced to, or if the ‘use_balanceTags’ option is set to true. |
wp-includes/pluggable.php: get_avatar() |
Retrieve the avatar |
wp-includes/formatting.php: wp_check_invalid_utf8() |
Checks for invalid UTF8 in a string. |
wp-includes/pluggable.php: wp_password_change_notification() |
Notify the blog admin of a user changing password, normally via email. |
wp-includes/pluggable.php: wp_new_user_notification() |
Email login credentials to a newly-registered user. |
wp-includes/pluggable.php: wp_notify_postauthor() |
Notify an author (and/or others) of a comment/trackback/pingback on a post. |
wp-includes/pluggable.php: wp_notify_moderator() |
Notifies the moderator of the site about a new comment that is awaiting approval. |
wp-includes/pluggable.php: wp_set_auth_cookie() |
Log in a user by setting authentication cookies. |
wp-includes/general-template.php: noindex() |
Displays a noindex meta tag if required by the blog configuration. |
wp-includes/general-template.php: get_the_modified_date() |
Retrieve the date on which the post was last modified. |
wp-includes/general-template.php: get_the_time() |
Retrieve the time at which the post was written. |
wp-includes/general-template.php: get_the_modified_time() |
Retrieve the time at which the post was last modified. |
wp-includes/general-template.php: wp_get_archives() |
Display archive links based on type and format. |
wp-includes/general-template.php: get_calendar() |
Display calendar with days that have posts as links. |
wp-includes/general-template.php: get_the_date() |
Retrieve the date on which the post was written. |
wp-includes/general-template.php: get_bloginfo() |
Retrieves information about the current site. |
wp-includes/general-template.php: wp_register() |
Display the Registration or Admin link. |
wp-includes/deprecated.php: get_boundary_post_rel_link() |
Get boundary post relational link. |
wp-includes/deprecated.php: get_parent_post_rel_link() |
Get parent post relational link. |
wp-includes/deprecated.php: get_current_theme() |
Retrieve current theme name. |
wp-includes/deprecated.php: make_url_footnote() |
Strip HTML and put links at the bottom of stripped content. |
wp-includes/deprecated.php: get_settings() |
Get value based on option. |
wp-includes/deprecated.php: get_links() |
Gets the links associated with category by id. |
wp-includes/class-wp-theme.php: WP_Theme::get_allowed_on_site() |
Returns array of stylesheet names of themes allowed on the site. |
wp-includes/class-wp.php: WP::send_headers() |
Sends additional HTTP headers for caching, content type, etc. |
wp-includes/class-wp-query.php: WP_Query::is_front_page() |
Is the query for the front page of the site? |
wp-includes/class-wp-query.php: WP_Query::get_queried_object() |
Retrieve queried object. |
wp-includes/class-wp-query.php: WP_Query::get_posts() |
Retrieves an array of posts based on query variables. |
wp-includes/class-wp-query.php: WP_Query::parse_query() |
Parse a query string and set query type booleans. |
wp-includes/load.php: wp_set_internal_encoding() |
Set internal encoding. |
wp-includes/load.php: wp_get_active_and_valid_plugins() |
Retrieve an array of active and valid plugin files. |
wp-includes/class-wp-http-proxy.php: WP_HTTP_Proxy::send_through_proxy() |
Whether URL should be sent through the proxy server. |
wp-includes/class-http.php: WP_Http::block_request() |
Block requests through the proxy. |
wp-includes/functions.php: wp_timezone_override_offset() |
gmt_offset modification for smart timezone handling. |
wp-includes/functions.php: wp_send_json() |
Send a JSON response back to an Ajax request. |
wp-includes/functions.php: smilies_init() |
Convert smiley code to the icon graphic file equivalent. |
wp-includes/functions.php: do_robots() |
Display the robots.txt file content. |
wp-includes/functions.php: date_i18n() |
Retrieve the date in localized format, based on a sum of Unix timestamp and timezone offset in seconds. |
wp-includes/functions.php: get_weekstartend() |
Get the week start and end from the datetime or date string from MySQL. |
wp-includes/functions.php: current_time() |
Retrieve the current time based on specified type. |
wp-includes/widgets/class-wp-widget-rss.php: WP_Widget_RSS::widget() |
Outputs the content for the current RSS widget instance. |
wp-includes/widgets/class-wp-widget-recent-comments.php: WP_Widget_Recent_Comments::widget() |
Outputs the content for the current Recent Comments widget instance. |
wp-includes/widgets.php: wp_widget_rss_output() |
Display the RSS entries in a list. |
wp-includes/widgets.php: wp_widgets_init() |
Registers all of the default WordPress widgets on startup. |
wp-includes/taxonomy.php: wp_unique_term_slug() |
Will make slug unique, if it isn’t already. |
wp-includes/taxonomy.php: wp_delete_term() |
Removes a term from the database. |
wp-includes/default-constants.php: wp_cookie_constants() |
Defines cookie related WordPress constants |
wp-includes/default-constants.php: wp_ssl_constants() |
Defines SSL-related WordPress constants. |
wp-includes/taxonomy.php: create_initial_taxonomies() |
Creates the initial taxonomies. |
wp-includes/default-constants.php: wp_plugin_directory_constants() |
Defines plugin directory WordPress constants |
wp-includes/link-template.php: wp_get_shortlink() |
Returns a shortlink for a post, page, attachment, or site. |
wp-includes/link-template.php: get_comments_pagenum_link() |
Retrieves the comments page number link. |
wp-includes/link-template.php: get_home_url() |
Retrieves the URL for a given site where the front end is accessible. |
wp-includes/link-template.php: get_site_url() |
Retrieves the URL for a given site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible. |
wp-includes/link-template.php: get_adjacent_post_link() |
Retrieves the adjacent post link. |
wp-includes/link-template.php: get_adjacent_post_rel_link() |
Retrieves the adjacent post relational link. |
wp-includes/link-template.php: get_post_type_archive_link() |
Retrieves the permalink for a post type archive. |
wp-includes/link-template.php: get_post_type_archive_feed_link() |
Retrieves the permalink for a post type archive feed. |
wp-includes/link-template.php: get_term_feed_link() |
Retrieves the feed link for a term. |
wp-includes/link-template.php: get_post_comments_feed_link() |
Retrieves the permalink for the post comments feed. |
wp-includes/link-template.php: get_author_feed_link() |
Retrieves the feed link for a given author. |
wp-includes/link-template.php: get_permalink() |
Retrieves the full permalink for the current post or post ID. |
wp-includes/link-template.php: get_page_link() |
Retrieves the permalink for the current page or page ID. |
wp-includes/link-template.php: get_attachment_link() |
Retrieves the permalink for an attachment. |
wp-includes/class-wp-ajax-response.php: WP_Ajax_Response::send() |
Display XML formatted responses. |
wp-includes/update.php: wp_update_plugins() |
Check plugin versions against the latest versions hosted on WordPress.org. |
wp-includes/update.php: wp_update_themes() |
Check theme versions against the latest versions hosted on WordPress.org. |
wp-includes/http.php: wp_http_validate_url() |
Validate a URL for safe use in the HTTP API. |
wp-includes/admin-bar.php: wp_admin_bar_edit_menu() |
Provide an edit link for posts and terms. |
wp-includes/plugin.php: register_uninstall_hook() |
Set the uninstallation hook for a plugin. |
wp-includes/feed.php: get_the_category_rss() |
Retrieve all of the post categories, formatted for use in feeds. |
wp-includes/feed.php: fetch_feed() |
Build SimplePie object based on RSS or Atom feed from URL. |
wp-includes/option.php: get_transient() |
Get the value of a transient. |
wp-includes/option.php: set_transient() |
Set/update the value of a transient. |
wp-includes/option.php: update_option() |
Update the value of an option that was already added. |
wp-includes/option.php: add_option() |
Add a new option. |
wp-includes/option.php: get_option() |
Retrieves an option value based on an option name. |
wp-includes/option.php: form_option() |
Print option value after sanitizing for forms. |
wp-includes/user.php: wp_update_user() |
Update a user in the database. |
wp-includes/user.php: register_new_user() |
Handles registering a new user. |
wp-includes/user.php: wp_insert_user() |
Insert a user into the database. |
wp-includes/user.php: get_blogs_of_user() |
Get the sites a user belongs to. |
wp-includes/bookmark-template.php: _walk_bookmarks() |
The formatted output of a list of bookmarks. |
wp-includes/nav-menu-template.php: _wp_menu_item_classes_by_context() |
Add the class property classes for the current context, if applicable. |
wp-includes/class-walker-page.php: Walker_Page::start_el() |
Outputs the beginning of the current element in the tree. |
wp-includes/post-template.php: _wp_link_page() |
Helper function for wp_link_pages(). |
wp-includes/post-template.php: wp_list_pages() |
Retrieve or display a list of pages (or hierarchical post type items) in list (li) format. |
wp-includes/post-template.php: wp_page_menu() |
Displays or retrieves a list of pages with an optional home link. |
wp-includes/media.php: wp_enqueue_media() |
Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs. |
wp-includes/media.php: image_constrain_size_for_editor() |
Scale down the default size of an image. |
wp-includes/post.php: _publish_post_hook() |
Hook to schedule pings and enclosures when a post is published. |
wp-includes/post.php: wp_unique_post_slug() |
Computes a unique slug for the post, when given the desired slug and some post details. |
wp-includes/post.php: wp_set_post_categories() |
Set categories for a post. |
wp-includes/post.php: wp_insert_post() |
Insert or update a post. |
wp-includes/post.php: _reset_front_page_settings_for_post() |
Reset the page_on_front, show_on_front, and page_for_post settings when a linked page is deleted or trashed. |
wp-includes/post.php: is_sticky() |
Determines whether a post is sticky. |
wp-includes/post.php: stick_post() |
Make a post sticky. |
wp-includes/post.php: unstick_post() |
Un-stick a post. |
wp-includes/class-wp-rewrite.php: WP_Rewrite::init() |
Sets up the object’s properties. |
wp-includes/class-wp-rewrite.php: WP_Rewrite::set_category_base() |
Sets the category base for the category permalink. |
wp-includes/class-wp-rewrite.php: WP_Rewrite::set_tag_base() |
Sets the tag base for the tag permalink. |
wp-includes/class-wp-rewrite.php: WP_Rewrite::wp_rewrite_rules() |
Retrieves the rewrite rules. |
wp-includes/class-wp-rewrite.php: WP_Rewrite::generate_rewrite_rules() |
Generates rewrite rules from a permalink structure. |
wp-includes/rewrite.php: url_to_postid() |
Examine a URL and try to determine the post ID it represents. |
wp-includes/canonical.php: redirect_canonical() |
Redirects incoming links to the proper URL based on the site url. |
wp-includes/revision.php: _wp_upgrade_revisions_of_post() |
Upgrade the revisions author, add the current post as a revision and set the revisions version to 1 |
wp-includes/ms-functions.php: get_space_allowed() |
Returns the upload quota for the current blog. |
wp-includes/ms-functions.php: maybe_add_existing_user_to_blog() |
Add a new user to a blog by visiting /newbloguser/{key}/. |
wp-includes/ms-functions.php: wpmu_welcome_user_notification() |
Notify a user that their account activation has been successful. |
wp-includes/ms-functions.php: global_terms() |
Maintains a canonical list of terms by syncing terms created for each blog with the global terms table. |
wp-includes/ms-functions.php: newblog_notify_siteadmin() |
Notifies the network admin that a new site has been activated. |
wp-includes/ms-functions.php: wpmu_welcome_notification() |
Notify a user that their blog activation has been successful. |
wp-includes/ms-functions.php: wpmu_signup_blog_notification() |
Send a confirmation request email to a user when they sign up for a new site. The new site will not become active until the confirmation link is clicked. |
wp-includes/ms-functions.php: wpmu_signup_user_notification() |
Send a confirmation request email to a user when they sign up for a new user account (without signing up for a site at the same time). The user account will not become active until the confirmation link is clicked. |
wp-includes/ms-blogs.php: get_blog_option() |
Retrieve option value for a given blog id based on name of option. |
wp-includes/nav-menu.php: _wp_auto_add_pages_to_menu() |
Automatically add newly published page objects to menus with that as an option. |
wp-includes/ms-blogs.php: get_blog_details() |
Retrieve the details for a blog from the blogs table and blog options. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::pingback_ping() |
Retrieves a pingback and registers it. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::_getOptions() |
Retrieve blog options value from list. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::blogger_getUsersBlogs() |
Retrieve blogs that user owns. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::wp_newComment() |
Create new comment. |
wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::wp_getUsersBlogs() |
Retrieve the blogs of the user. |
wp-includes/ms-default-constants.php: ms_cookie_constants() |
Defines Multisite cookie constants. |
wp-includes/class-wp-widget.php: WP_Widget::get_settings() |
Retrieves the settings for all instances of the widget class. |
wp-includes/widgets.php: is_dynamic_sidebar() |
Determines whether the dynamic sidebar is enabled and used by the theme. |
wp-includes/widgets.php: wp_get_sidebars_widgets() |
Retrieve full list of sidebars and their widget instance IDs. |
wp-includes/widgets.php: wp_convert_widget_settings() |
Convert the widget settings from single to multi-widget format. |
wp-includes/comment-template.php: get_post_reply_link() |
Retrieve HTML content for reply to post link. |
wp-includes/comment-template.php: wp_list_comments() |
List comments. |
wp-includes/comment-template.php: comment_form() |
Outputs a complete commenting form for use within a template. |
wp-includes/comment-template.php: get_trackback_url() |
Retrieve The current post’s trackback URL. |
wp-includes/comment-template.php: comments_template() |
Load the comment template specified in $file. |
wp-includes/comment-template.php: get_comment_reply_link() |
Retrieve HTML content for reply to comment link. |
wp-includes/comment-template.php: get_comment_link() |
Retrieve the link to a given comment. |
wp-includes/comment-template.php: get_comment_time() |
Retrieve the comment time of the current comment. |
wp-includes/comment-template.php: get_comment_date() |
Retrieve the comment date of the current comment. |
wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::preview_sidebars_widgets() |
When previewing, ensures the proper previewing widgets are used. |
wp-includes/comment.php: privacy_ping_filter() |
Check whether blog is public before returning sites. |
wp-includes/comment.php: trackback() |
Send a Trackback. |
wp-includes/comment.php: weblog_ping() |
Send a pingback. |
wp-includes/comment.php: _close_comments_for_old_posts() |
Close comments on old posts on the fly, without any extra DB queries. Hooked to the_posts. |
wp-includes/comment.php: _close_comments_for_old_post() |
Close comments on an old post. Hooked to comments_open and pings_open. |
wp-includes/comment.php: generic_ping() |
Sends pings to all of the ping site services. |
wp-includes/comment.php: get_comment_pages_count() |
Calculate the total number of comment pages. |
wp-includes/comment.php: get_page_of_comment() |
Calculate what page number a comment will appear on for comment paging. |
wp-includes/comment.php: wp_blacklist_check() |
Does comment contain blacklisted characters or words. |
wp-includes/comment.php: check_comment() |
Check whether a comment passes internal checks to be allowed to add. |
User Contributed Notes #User Contributed Notes
You must log in before being able to contribute a note or feedback.
Handling of non-existing options
Show Blog Title
Displays your blog’s title in a
<h1>
tag.Show Character Set
Displays the character set your blog is using (ex: UTF-8)
Retrieve Administrator E-mail
Retrieve the e-mail of the blog administrator, storing it in a variable.
A quick tip that the output of
get_option()
is filterable:So you can change the output of
get_option()
at run time.Helpful for disabling specific plugins when required.
https://developer.wordpress.org/reference/hooks/option_option/
If you want to get a network-wide option, use the get_site_option function instead. https://developer.wordpress.org/reference/functions/get_site_option
Just like we use
to incorporate the date format defined in Settings -> General,
We can also use
to incorporate the time format defined in Settings -> General.
for example
There is a “long-hand” format for creating option settings-field parameter in one line that is harder to read/follow semantically, but provides a single string to a options setting instead of two strings for every option.
The above returns false, so technically there is no default to setup unless you require a value.
And there are just a bit less parameter parsing than
Alternatively (if default required):
And for a checkbox in a settings array, try:
check options exists or not, use isset to check
if value exists then checked box appear, if there is no option then unchecked box appears