Contents
How do I find the text domain in WordPress?
php or it is contained in a folder called my-plugin , the text domain should be my-plugin . If your plugin is hosted on WordPress.org, it must be the slug of your plugin URL ( wordpress.org/plugins/ ).
How do I create a text domain in WordPress?
The text domain is a unique identifier WordPress uses to distinguish between all the loaded translation, every theme/plugin in WordPress should have a unique text domain in order to make it possible the WordPress localization functions to work properly.
What is use of __ and _e () functions in WordPress?
If you want to echo the translated string, then you will be using _e and when you just want to have the translated string, then you will be using __ . Example: _e(‘this is a message’, ‘twentyfourteen’); is same as echo __(‘this is a message’, ‘twentyfourteen’);
What is the use of Esc_html_e?
esc_html_e() and esc_html__() are similar, but they are used for strings that do contain markup. They each escape the provided string, and then call on their corresponding _e() or __() counterparts depending on which one you use. Escaping HTML is necessary if you’re accepting strings provided from user input.
Why do you need a text domain in WordPress?
The text domain is a unique identifier to ensure WordPress can distinguish between all loaded translations. This increases portability and plays better with already existing WordPress tools. The text domain must match the slug of the plugin.
Can you use WordPress core strings without text domain?
For the same reasons you shouldn’t use WordPress core strings, without your project’s text domain, in your plugin or theme either. To distinguish between strings coming from WordPress core and the different plugins and themes on your site, WordPress uses a so-called text domain.
What should the domain name of a WordPress plugin be?
If your plugin is a single file called my-plugin.php or it is contained in a folder called my-plugin the domain name should be my-plugin. If your plugin is hosted on wordpress.org it must be the slug of your plugin URL ( wordpress.org/plugins/ ). The text domain name must use dashes and not underscores.
How to host a theme on WordPress.org?
Themes that are hosted on WordPress.org the text domain must match the slug of your theme URL ( wordpress.org/themes/ ). This is needed so that the translations from translate.wordpress.org work correctly. The text domain name must use dashes and not underscores and be lowercase.