_x() WordPress Function
The x() function is a utility function for translating strings of text. It is used to wrap strings of text that should be translated into the current language. When a string is wrapped in the x() function, it tells WordPress to translate the string into the current language.
_x( string $text, string $context, string $domain = 'default' ) #
Retrieve translated string with gettext context.
Description
Quite a few times, there will be collisions with similar translatable text found in more than two places, but with different translated context.
By including the context in the pot file, translators can translate the two strings differently.
Parameters
- $text
(string)(Required)Text to translate.
- $context
(string)(Required)Context information for the translators.
- $domain
(string)(Optional) Text domain. Unique identifier for retrieving translated strings.
Default value: 'default'
Return
(string) Translated context string without pipe.
Source
File: wp-includes/l10n.php
function _x( $text, $context, $domain = 'default' ) { return translate_with_gettext_context( $text, $context, $domain ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Related
Uses
Uses | Description |
---|---|
wp-includes/l10n.php:translate_with_gettext_context() | Retrieve the translation of $text in the context defined in $context. |
Used By
Used By | Description |
---|---|
wp-includes/widgets/class-wp-widget-media.php:WP_Widget_Media::get_l10n_defaults() | Returns the default localized strings used by the widget. |
wp-includes/class-wp-taxonomy.php:WP_Taxonomy::get_default_labels() | Returns the default labels for taxonomies. |
wp-includes/class-wp-post-type.php:WP_Post_Type::get_default_labels() | Returns the default labels for post types. |
wp-includes/block-template-utils.php:get_default_block_template_types() | Returns a filtered list of default template types, containing their localized titles and descriptions. |
wp-includes/block-editor.php:get_default_block_categories() | Returns the list of default categories for block types. |
wp-includes/ms-functions.php:wpmu_new_site_admin_notification() | Notifies the Multisite network administrator that a new site was created. |
wp-includes/block-patterns.php:_register_core_block_patterns_and_categories() | Registers the core block patterns and categories. |
wp-includes/theme.php:validate_theme_requirements() | Validates the theme requirements for WordPress version and PHP version. |
wp-admin/includes/class-plugin-installer-skin.php:Plugin_Installer_Skin::do_overwrite() | Check if the plugin can be overwritten and output the HTML for overwriting a plugin on upload. |
wp-admin/includes/class-theme-installer-skin.php:Theme_Installer_Skin::do_overwrite() | Check if the theme can be overwritten and output the HTML for overwriting a theme on upload. |
wp-admin/includes/credits.php:wp_credits_section_title() | Displays the title for a given group of contributors. |
wp-admin/includes/template.php:get_post_states() | Retrieves an array of post states from a post. |
wp-admin/includes/class-wp-debug-data.php:WP_Debug_Data::debug_data() | Static function for generating site debug data when required. |
wp-admin/includes/plugin.php:validate_plugin_requirements() | Validates the plugin requirements for WordPress version and PHP version. |
wp-includes/functions.php:wp_get_default_update_php_url() | Gets the default URL to learn more about updating the PHP version the site is running on. |
wp-admin/includes/post.php:taxonomy_meta_box_sanitize_cb_input() | Sanitizes POST values from an input taxonomy metabox. |
wp-includes/script-loader.php:wp_default_packages_scripts() | Registers all the WordPress packages scripts that are in the standardized |
wp-admin/includes/meta-boxes.php:register_and_do_post_meta_boxes() | Registers the default post meta boxes, and runs the |
wp-includes/post.php:_wp_privacy_statuses() | Return statuses for privacy requests. |
wp-admin/includes/privacy-tools.php:wp_privacy_generate_personal_data_export_file() | Generate the personal data export file. |
wp-includes/widgets/class-wp-widget-media-gallery.php:WP_Widget_Media_Gallery::__construct() | Constructor. |
wp-includes/customize/class-wp-customize-nav-menu-locations-control.php:WP_Customize_Nav_Menu_Locations_Control::content_template() | JS/Underscore template for the control UI. |
wp-includes/widgets/class-wp-widget-media-audio.php:WP_Widget_Media_Audio::__construct() | Constructor. |
wp-includes/widgets/class-wp-widget-media-video.php:WP_Widget_Media_Video::__construct() | Constructor. |
wp-includes/widgets/class-wp-widget-media-image.php:WP_Widget_Media_Image::__construct() | Constructor. |
wp-admin/includes/dashboard.php:wp_dashboard_events_news() | Renders the Events and News dashboard widget. |
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/theme.php:get_theme_starter_content() | Expands a theme’s starter content configuration using core-provided data. |
wp-includes/class-wp-editor.php:_WP_Editors::get_translation() | |
wp-admin/includes/update.php:wp_print_update_row_templates() | Prints the JavaScript templates for update and deletion rows in list tables. |
wp-includes/class-wp-customize-manager.php:WP_Customize_Manager::customize_pane_settings() | Prints JavaScript settings for parent window. |
wp-includes/general-template.php:wp_get_document_title() | Returns document title for the current page. |
wp-includes/functions.php:wp_maybe_decline_date() | Determines if the date should be declined. |
wp-admin/includes/class-wp-screen.php:WP_Screen::render_meta_boxes_preferences() | Render the meta boxes preferences. |
wp-admin/includes/class-wp-users-list-table.php:WP_Users_List_Table::get_role_list() | Returns an array of translated user role names for a given user object. |
wp-includes/customize/class-wp-customize-nav-menu-setting.php:WP_Customize_Nav_Menu_Setting::sanitize() | Sanitize an input. |
wp-includes/class-wp-customize-nav-menus.php:WP_Customize_Nav_Menus::search_available_items_query() | Performs post queries for available-item searching. |
wp-includes/class-wp-customize-nav-menus.php:WP_Customize_Nav_Menus::enqueue_scripts() | Enqueues scripts and styles for Customizer pane. |
wp-includes/class-wp-customize-nav-menus.php:WP_Customize_Nav_Menus::customize_register() | Adds the customizer settings and controls. |
wp-includes/class-wp-customize-nav-menus.php:WP_Customize_Nav_Menus::load_available_items_query() | Performs the post_type and taxonomy queries for loading available menu items. |
wp-admin/includes/class-wp-posts-list-table.php:WP_Posts_List_Table::handle_row_actions() | Generates and displays row action links. |
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-comments-list-table.php:WP_Comments_List_Table::handle_row_actions() | Generate and display row actions links. |
wp-admin/includes/class-wp-ms-sites-list-table.php:WP_MS_Sites_List_Table::handle_row_actions() | Generates and displays row action links. |
wp-admin/includes/class-wp-ms-users-list-table.php:WP_MS_Users_List_Table::column_name() | Handles the name column output. |
wp-includes/customize/class-wp-customize-theme-control.php:WP_Customize_Theme_Control::content_template() | Render a JS template for theme display. |
wp-includes/post-template.php:the_meta() | Displays a list of post custom fields. |
wp-admin/includes/theme.php:customize_themes_print_templates() | Prints JS templates for the theme-browsing UI in the Customizer. |
wp-admin/includes/upgrade.php:wp_install_maybe_enable_pretty_permalinks() | Maybe enable pretty permalinks on installation. |
wp-includes/general-template.php:get_the_archive_title() | Retrieve the archive title based on the queried object. |
wp-includes/link-template.php:get_the_posts_pagination() | Retrieves a paginated navigation to next/previous set of posts, when applicable. |
wp-includes/l10n.php:wp_dropdown_languages() | Language selector. |
wp-includes/comment-template.php:get_comments_number_text() | Displays the language string for the number of comments the current post has. |
wp-login.php:login_footer() | Outputs the footer for the login page. |
wp-admin/includes/network.php:network_step1() | Prints step 1 for Network installation process. |
wp-admin/includes/class-wp-ms-users-list-table.php:WP_MS_Users_List_Table::get_bulk_actions() | |
wp-admin/includes/class-wp-ms-users-list-table.php:WP_MS_Users_List_Table::get_columns() | |
wp-admin/includes/theme.php:get_theme_update_available() | Retrieves the update link if there is a theme update available. |
wp-admin/includes/class-wp-plugins-list-table.php:WP_Plugins_List_Table::single_row() | |
wp-admin/includes/class-wp-links-list-table.php:WP_Links_List_Table::get_columns() | |
wp-admin/includes/class-theme-upgrader-skin.php:Theme_Upgrader_Skin::after() | Action to perform following a single theme update. |
wp-admin/includes/class-theme-installer-skin.php:Theme_Installer_Skin::after() | Action to perform following a single theme install. |
wp-admin/includes/class-wp-list-table.php:WP_List_Table::pagination() | Displays the pagination. |
wp-admin/includes/class-wp-theme-install-list-table.php:WP_Theme_Install_List_Table::install_theme_info() | Prints the info for a theme (to be used in the theme installer modal). |
wp-admin/includes/schema.php:populate_options() | Create WordPress options and set the default values. |
wp-admin/includes/class-wp-theme-install-list-table.php:WP_Theme_Install_List_Table::prepare_items() | |
wp-admin/includes/class-wp-theme-install-list-table.php:WP_Theme_Install_List_Table::single_row() | Prints a theme from the WordPress.org API. |
wp-admin/includes/update.php:wp_plugin_update_row() | Displays update information for a plugin. |
wp-admin/includes/update.php:wp_theme_update_row() | Displays update information for a theme. |
wp-admin/includes/plugin-install.php:install_plugin_information() | Displays plugin information in dialog box form. |
wp-admin/includes/dashboard.php:wp_dashboard_recent_posts() | Generates Publishing Soon and Recently Published sections. |
wp-admin/includes/deprecated.php:wp_dashboard_plugins_output() | Display plugins text for the WordPress news widget. |
wp-admin/includes/dashboard.php:wp_dashboard_recent_drafts() | Show recent drafts of the user on the dashboard. |
wp-admin/includes/dashboard.php:_wp_dashboard_recent_comments_row() | Outputs a row for the Recent Comments widget. |
wp-admin/includes/upgrade.php:wp_install_defaults() | Creates the initial content for a newly-installed site. |
wp-admin/includes/class-wp-plugin-install-list-table.php:WP_Plugin_Install_List_Table::display_rows() | |
wp-admin/includes/class-wp-plugin-install-list-table.php:WP_Plugin_Install_List_Table::prepare_items() | |
wp-admin/includes/template.php:list_meta() | Outputs a post’s public meta data in the Custom Fields meta box. |
wp-admin/includes/class-wp-themes-list-table.php:WP_Themes_List_Table::display_rows() | |
wp-admin/includes/class-wp-ms-sites-list-table.php:WP_MS_Sites_List_Table::__construct() | Constructor. |
wp-admin/includes/class-wp-ms-sites-list-table.php:WP_MS_Sites_List_Table::get_bulk_actions() | |
wp-admin/includes/class-wp-ms-sites-list-table.php:WP_MS_Sites_List_Table::get_columns() | |
wp-admin/includes/class-wp-users-list-table.php:WP_Users_List_Table::single_row() | Generate HTML for a single row on the users.php admin panel. |
wp-admin/includes/class-wp-users-list-table.php:WP_Users_List_Table::get_columns() | Get a list of columns for the list table. |
wp-admin/includes/post.php:bulk_edit_posts() | Processes the post data for the bulk editing of posts. |
wp-admin/includes/revision.php:wp_prepare_revisions_for_js() | Prepare revisions for JavaScript. |
wp-admin/includes/ajax-actions.php:wp_ajax_ajax_tag_search() | Ajax handler for tag search. |
wp-admin/includes/ajax-actions.php:wp_ajax_autocomplete_user() | Ajax handler for user autocomplete. |
wp-admin/includes/meta-boxes.php:post_submit_meta_box() | Displays post submit form fields. |
wp-admin/includes/meta-boxes.php:attachment_submit_meta_box() | Displays attachment submit form fields. |
wp-admin/includes/meta-boxes.php:post_tags_meta_box() | Displays post tags form fields. |
wp-admin/includes/class-wp-media-list-table.php:WP_Media_List_Table::get_views() | |
wp-admin/includes/class-wp-media-list-table.php:WP_Media_List_Table::get_columns() | |
wp-admin/includes/class-wp-media-list-table.php:WP_Media_List_Table::_get_row_actions() | |
wp-admin/includes/class-wp-post-comments-list-table.php:WP_Post_Comments_List_Table::get_column_info() | |
wp-admin/includes/class-wp-comments-list-table.php:WP_Comments_List_Table::get_bulk_actions() | |
wp-admin/includes/class-wp-comments-list-table.php:WP_Comments_List_Table::get_columns() | |
wp-admin/includes/class-wp-terms-list-table.php:WP_Terms_List_Table::get_columns() | |
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/class-wp-posts-list-table.php:WP_Posts_List_Table::get_columns() | |
wp-admin/includes/class-custom-image-header.php:Custom_Image_Header::step_1() | Display first step of custom header image page. |
wp-includes/class-wp-customize-manager.php:WP_Customize_Manager::register_controls() | Registers some default controls. |
wp-includes/l10n.php:_ex() | Display translated string with gettext context. |
wp-includes/formatting.php:capital_P_dangit() | Forever eliminate “Wordpress” from the planet (or at least the little bit we can influence). |
wp-includes/formatting.php:wp_trim_excerpt() | Generates an excerpt from the content, if needed. |
wp-includes/formatting.php:wp_trim_words() | Trims text to a certain number of words. |
wp-includes/formatting.php:wptexturize() | Replaces common plain text characters with formatted entities. |
wp-includes/general-template.php:register_admin_color_schemes() | Registers the default admin color schemes. |
wp-includes/general-template.php:feed_links() | Display the links to the general feeds. |
wp-includes/general-template.php:feed_links_extra() | Display the links to the extra feeds such as category feeds. |
wp-includes/general-template.php:get_calendar() | Display calendar with days that have posts as links. |
wp-includes/general-template.php:get_search_form() | Display search form. |
wp-includes/class-wp-theme.php:WP_Theme::translate_header() | Translates a theme header. |
wp-includes/class-wp-query.php:WP_Query::get_search_stopwords() | Retrieve stopwords used when parsing search terms. |
wp-includes/functions.php:size_format() | Converts a number of bytes to the largest unit the bytes will fit into. |
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/class-wp-widget-search.php:WP_Widget_Search::__construct() | Sets up a new Search widget instance. |
wp-includes/class-wp-locale.php:WP_Locale::init() | Sets up the translated strings and object properties. |
wp-includes/taxonomy.php:create_initial_taxonomies() | Creates the initial taxonomies. |
wp-includes/admin-bar.php:wp_admin_bar_new_content_menu() | Adds “Add New” menu. |
wp-includes/user.php:wp_insert_user() | Inserts a user into the database. |
wp-includes/user.php:wp_dropdown_users() | Creates dropdown HTML content of users. |
wp-includes/post-template.php:wp_post_revision_title() | Retrieves formatted date timestamp of a revision (linked to that revisions’s page). |
wp-includes/post-template.php:wp_post_revision_title_expanded() | Retrieves formatted date timestamp of a revision (linked to that revisions’s page). |
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:wp_underscore_playlist_templates() | Outputs the templates used by playlists. |
wp-includes/media.php:wp_get_attachment_id3_keys() | Returns useful keys to use to lookup data from an attachment’s stored metadata. |
wp-includes/post.php:wp_set_post_terms() | Set the terms for a post. |
wp-includes/post.php:get_post_mime_types() | Get default post mime types. |
wp-includes/post.php:create_initial_post_types() | Creates the initial post types when ‘init’ action is fired. |
wp-includes/ms-functions.php:wpmu_signup_blog_notification() | Sends 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() | Sends 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/post-formats.php:get_post_format_strings() | Returns an array of post format slugs to their translated and pretty display versions |
wp-includes/comment-template.php:comment_form() | Outputs a complete commenting form for use within a template. |
wp-includes/comment-template.php:comment_type() | Displays the comment type of the current comment. |
wp-includes/comment-template.php:get_comment_excerpt() | Retrieves the excerpt of the given comment. |
wp-includes/class-wp-customize-widgets.php:WP_Customize_Widgets::enqueue_scripts() | Enqueues scripts and styles for Customizer panel and export data to JavaScript. |
wp-includes/script-loader.php:wp_default_styles() | Assigns default styles to $styles object. |
wp-includes/script-loader.php:wp_just_in_time_script_localization() | Loads localized data on print rather than initialization. |
wp-includes/script-loader.php:wp_default_scripts() | Registers all WordPress scripts. |
wp-includes/comment.php:get_comment_statuses() | Retrieves all of the WordPress supported comment statuses. |
wp-includes/class-wp-editor.php:_WP_Editors::editor() | Outputs the HTML for a single instance of the editor. |
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |