WordPress at a glance
Главная Functions Other Functions

Category: Other Functions

Helper Functions

__return_empty_array()

Simply returns an empty array: array(). Helper function of WordPress.

__return_empty_string()

Simply returns an empty string:". Helper function of WordPress.

__return_false()

Simply returns false. Helper function of WordPress.

__return_null()

Simply returns null. Auxiliary function of WordPress.

__return_true()

Simply returns true. Helper function of WordPress.

__return_zero()

Simply returns 0. Helper function of WordPress. Useful for use in filters.

get_page_hierarchy()

Order the pages with children under parents in a flat list.

get_temp_dir()

Determine a writable directory for temporary files.

is_email()

Verifies that an email is valid.

is_serialized()

Check value to find if it was serialized.

is_serialized_string()

Check whether serialized data is of string type.

map_deep()

Maps a function to all non-iterable elements of an array or an object.

maybe_serialize()

Serialize data, if needed.

maybe_unserialize()

Unserialize value only if it was serialized.

path_join()

Join two filesystem paths together.

seems_utf8()

Checks to see if a string is utf8 encoded.

stripslashes_deep()

Navigates through an array, object, or scalar, and removes slashes from the values.

timer_stop()

Retrieve or display the time from the page start to when function is called.

urlencode_deep()

Navigates through an array, object, or scalar, and encodes the values to be used in a URL.

wp_array_slice_assoc()

Extract a slice of an array, given a list of keys.

wp_basename()

i18n friendly version of basename()

wp_doing_ajax()

Determines whether the current request is a WordPress Ajax request.

wp_extract_urls()

Use RegEx to extract URLs from arbitrary content.

wp_filter_object_list()

Filters a list of objects, based on a set of key => value arguments.

wp_generate_uuid4()

Generate a random UUID (version 4).

wp_is_numeric_array()

Determines if the variable is a numeric-indexed array.

wp_is_uuid()

Validates that a UUID is valid.

wp_json_encode()

Encode a variable into JSON, with some sanity checks. Checks strings and translates them to UTF-8.

wp_kses_array_lc()

Goes through an array and changes the keys to all lower case.

wp_kses_hair()

Builds an attribute list from string containing attributes.

wp_list_filter()

Filters a list of objects, based on a set of key => value arguments.

wp_list_pluck()

Pluck a certain field out of each object in a list.

wp_list_sort()

Sorts a list of objects, based on one or more orderby arguments.

wp_make_link_relative()

Convert full URL paths to absolute paths.

wp_mkdir_p()

Recursive directory creation based on full path.

wp_normalize_path()

Normalize a filesystem path.

wp_parse_args()

Merge user defined arguments into defaults array.

wp_parse_id_list()

Clean up an array, comma- or space-separated list of IDs.

wp_parse_slug_list()

Clean up an array, comma- or space-separated list of slugs.

wp_parse_str()

Parses a string into variables to be stored in an array.

wp_rand()

Generates a random number between the specified min and max.

wp_reset_vars()

Resets global variables based on $_GET and $_POST

wp_send_json()

Send a JSON response back to an Ajax request.

wp_send_json_error()

Send a JSON response back to an Ajax request, indicating failure.

wp_send_json_success()

Returns JSON data. Is used to return a success response to AJAX request. The response object always contains the element success=true. die() php execution.

wp_slash()

Add slashes to a string or array of strings.

wp_spaces_regexp()

Returns the regexp for common whitespace characters.

wp_tempnam()

Returns a filename of a Temporary unique file. Please note that the calling function must unlink() this itself.

wp_unslash()

Remove slashes from a string or array of strings.

wp_validate_boolean()

Filter/validate a variable as a boolean.

Scripts and Styles

add_editor_style()

Links (connect) specified stylesheets CSS file to the TinyMCE visual editor.

wp_add_inline_script()

Adds extra code to a registered script.

wp_add_inline_style()

Add extra CSS styles to a registered stylesheet.

wp_dequeue_script()

Remove a previously enqueued script.

wp_deregister_script()

Remove a registered script.

wp_enqueue_code_editor()

Enqueue assets needed by the code editor for the given settings.

wp_enqueue_editor()

Outputs the editor scripts, stylesheets, and default settings.

wp_enqueue_media()

Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs.

wp_enqueue_script()

Enqueue a script. Registers the script if $src provided (does NOT overwrite), and enqueues it.

wp_enqueue_style()

Enqueue a CSS stylesheet.

wp_localize_jquery_ui_datepicker()

Localizes the jQuery UI datepicker.

wp_localize_script()

Localize a script. Works only if the script has already been added.

wp_register_script()

Register a new script.

wp_register_style()

Register a CSS stylesheet.

wp_script_add_data()

Add metadata to a script.

wp_script_is()

Check whether a script has been added to the queue.

wp_style_add_data()

Add metadata to a CSS stylesheet.

wp_style_is()

Check whether a CSS stylesheet has been added to the queue.

Admin Menu

add_menu_page()

Add a top-level menu page.

add_meta_box()

Adds a meta box to one or more screens.

add_options_page()

Add submenu page to the Settings main menu.

add_submenu_page()

Add a submenu page. This function takes a capability which will be used to determine whether or not a page is included in the menu.

add_theme_page()

Add submenu page to the Appearance main menu.

do_meta_boxes()

Meta-Box template function

get_admin_url()

Retrieves the URL to the admin area for a given site.

get_current_screen()

Get the current screen object

includes_url()

Retrieves the URL to the includes directory.

is_admin()

Whether the current request is for an administrative interface page.

remove_menu_page()

Remove a top-level admin menu.

remove_meta_box()

Removes a meta box from one or more screens.

remove_submenu_page()

Remove an admin submenu.

wp_add_dashboard_widget()

Adds a new dashboard widget.

wp_maintenance()

Die with a maintenance message when conditions are met.

Metadata

add_metadata()

Add metadata for the specified object.

delete_metadata()

Delete metadata for the specified object.

get_metadata()

Retrieve metadata for the specified object.

is_protected_meta()

Determine whether a meta key is protected.

register_meta()

Registers a meta key.

sanitize_meta()

Sanitize meta value.

update_metadata()

Update metadata for the specified object. If no value already exists for the specified object ID and metadata key, the metadata will be added.

Site Options (settings)

add_option()

Add a new option. You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is inserted into the database. Remember, resources can not be serialized or added as an option.

admin_url()

Retrieves the URL to the admin area for the current site. Takes into account protocols (http and https).

delete_option()

Removes option by name. Prevents removal of protected WordPress options.

get_bloginfo()

Retrieves information about the current site.

get_home_url()

Retrieves the URL for a given site where the front end is accessible.

get_option()

Retrieves an option value based on an option name.

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.

home_url()

Retrieves the URL for the current site where the front end is accessible.

is_ssl()

Determines if SSL is used.

site_url()

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

update_option()

Update the value of an option that was already added.

wp_load_alloptions()

Loads and caches all autoloaded options, if available or all options.

Main Query

add_query_arg()

Retrieves a modified URL query string.

get_queried_object()

Retrieve the currently-queried object.

get_queried_object_id()

Retrieve ID of the current queried object.

get_query_var()

Retrieve variable in the WP_Query class.

get_search_query()

Retrieves the contents of the search WordPress query variable.

get_status_header_desc()

Retrieve the description for the HTTP status.

is_embed()

Is the query for an embedded post?

is_robots()

Is the query for the robots file?

redirect_canonical()

Redirects incoming links to the proper URL based on the site url.

remove_query_arg()

Removes an item or items from a query string.

wp{}

Set up the WordPress query.

Uncategorized

cache_javascript_headers()

Set the headers for caching for 10 days with JavaScript content type.

do_robots()

Display the robots.txt file content.

download_url()

Downloads a URL to a local temporary file using the WordPress HTTP Class. Please note, That the calling function must unlink() the file.

is_blog_installed()

Test whether WordPress is already installed.

is_wp_error()

Check whether variable is a WordPress Error.

maybe_convert_table_to_utf8mb4()

If a table only contains utf8 or utf8mb4 columns, convert it to utf8mb4.

nocache_headers()

Set the headers to prevent caching for the different browsers.

show_admin_bar()

Sets the display status of the admin bar.

wp_check_browser_version()

Check if the user needs a browser update

wp_die()

Kill WordPress execution and display HTML message with error message.

wp_editor()

Renders an editor. Using this function is the proper way to output all needed components for both TinyMCE and Quicktags. _WP_Editors should not be used directly. See https://core.trac.wordpress.org/ticket/17144.

wp_magic_quotes()

Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.

wp_mail()

Send mail, similar to PHP's mail

wp_oembed_get()

Embeds the object by specified URL. Tries to get the HTML code from the passed URL by using supported WordPress oEmbed providers.

wp_redirect()

Redirects to another page.

wp_safe_redirect()

Performs a safe redirect, using wp_redirect(). Before redirections check whether the host is in whitelist (in list of allowed hosts).

wp_star_rating()

Output a HTML element with a star rating for a given rating.

wp_timezone_choice()

Gives a nicely-formatted list of timezone strings.

Date/Time

calendar_week_mod()

Get number of days since the start of the week.

current_time()

Retrieve the current time based on specified type.

get_calendar()

Display calendar with days that have posts as links.

get_date_from_gmt()

Converts a GMT date into the correct format for the blog.

get_gmt_from_date()

Returns a date in the GMT equivalent.

get_weekstartend()

Get the week start and end from the datetime or date string from MySQL.

human_time_diff()

Determines the difference between two timestamps.

mysql2date()

Convert given date string into a different format.

Security

check_admin_referer()

Makes sure that a user was referred from another admin page.

check_ajax_referer()

Verifies the Ajax request to prevent processing requests external of the blog.

wp_create_nonce()

Creates a cryptographic token tied to a specific action, user, user session, and window of time.

wp_generate_password()

Generates a random password drawn from the defined set of characters.

wp_hash()

Gets hash of a given string.

wp_hash_password()

Encrypts the specified text to make a password hash from it.

wp_http_validate_url()

Validate a URL for safe use in the HTTP API.

wp_kses_post()

Sanitize content for allowed HTML tags for post content.

wp_nonce_ays()

Display "Are You Sure" message to confirm the action being taken.

wp_nonce_field()

Retrieve or display nonce hidden field for forms.

wp_nonce_url()

Retrieve URL with nonce added to URL query.

wp_referer_field()

Retrieve or display referer hidden field for forms.

wp_salt()

Get salt to add to hashes.

wp_sanitize_redirect()

Sanitizes a URL for use in a redirect.

wp_verify_nonce()

Verify that correct nonce was used with time limit.

Form Helpers

checked()

Outputs the html checked attribute.

disabled()

Outputs the html disabled attribute.

readonly()

Outputs the html readonly attribute.

selected()

Outputs the html selected attribute.

File system (WP_Filesystem)

copy_dir()

Copies a directory from one location to another via the WordPress Filesystem Abstraction. Assumes that WP_Filesystem() has already been called and setup.

list_files()

Returns a listing of all files in the specified folder and all subdirectories up to 100 levels deep. The depth of the recursiveness can be controlled by the $levels param.

unzip_file()

Unzips a specified ZIP file to a location on the Filesystem via the WordPress Filesystem Abstraction. Assumes that WP_Filesystem() has already been called and set up. Does not extract a root-level __MACOSX directory, if present.

SQL

dbDelta()

Creates or modifies database tables based on the specified SQL query to create table.

esc_sql()

Escapes data for use in a MySQL query.

get_meta_sql()

Given a meta query, generates SQL clauses to be appended to a main query.

get_num_queries()

Retrieve the number of database queries during the WordPress execution.

get_posts_by_author_sql()

Retrieve the post SQL based on capability, author, and type.

sanitize_sql_orderby()

Ensures a string is a valid SQL 'order by' clause.

Transient Options

delete_expired_transients()

Deletes all expired transients.

delete_transient()

Delete a transient.

get_transient()

Get the value of a transient.

set_transient()

Set/update the value of a transient.

Bookmarks

edit_bookmark_link()

Displays the edit bookmark link anchor content.

get_bookmark()

Retrieve Bookmark data

get_bookmarks()

Retrieves the list of bookmarks

wp_list_bookmarks()

Retrieve or echo all of the bookmarks.

Emoji

wp_encode_emoji()

Convert emoji characters to their equivalent HTML entity.

wp_staticize_emoji()

Convert emoji to a static img element.