WPMU Functions/load muplugin textdomain

来自WordPress中文文档
Zhuozuran讨论 | 贡献2016年5月6日 (五) 06:13的版本 (1个版本)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

Description

Loads the plugin's translated strings.

This function is the same as load_plugin_textdomain however it is designed for the mu-plugins directory rather than its WordPress equivalent which is designed for the normal plugins directory.

Parameters

tt$domain/tt
(string) (required) Unique identifier for retrieving translated strings.
Default: Nonenoinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Notes

This template is for standardizing how parameters look in the Function Reference and in Template Tags. Here is an example of this template being called: prenowiki检查到模板循环:模板:Parameter/nowiki/pre 检查到模板循环:模板:Parameter

The usage of this template is below: prenowiki检查到模板循环:模板:Parameter/nowiki/pre Let's take a closer look at the parameters..

name
The name of the parameter.
datatype
The datatype that should be given for this parameter when called.
  • string
  • integer
  • boolean
  • mixed
description
A short description of the parameter.
importance
Set this parameter to optional if the parameter is optional. Otherwise, do not declare this parameter—it defaults to required.
  • required
  • optional
default
If this parameter is optional, ttdefault/tt is the value that will be used if the parameter is not declared.

wordpress.org.cn /div /noinclude

tt$mu_plugin_rel_path/tt
(string) (optional) Relative path to the location of the .mo files.
Default: falsenoinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Notes

This template is for standardizing how parameters look in the Function Reference and in Template Tags. Here is an example of this template being called: prenowiki检查到模板循环:模板:Parameter/nowiki/pre 检查到模板循环:模板:Parameter

The usage of this template is below: prenowiki检查到模板循环:模板:Parameter/nowiki/pre Let's take a closer look at the parameters..

name
The name of the parameter.
datatype
The datatype that should be given for this parameter when called.
  • string
  • integer
  • boolean
  • mixed
description
A short description of the parameter.
importance
Set this parameter to optional if the parameter is optional. Otherwise, do not declare this parameter—it defaults to required.
  • required
  • optional
default
If this parameter is optional, ttdefault/tt is the value that will be used if the parameter is not declared.

wordpress.org.cn /div /noinclude

Return Values

boolean 
Returns true if the language file was loaded successfully. Returns false, if the language file could not be loaded (it is not readable or the mo file reader can not understand it).

Usage

%%%<?php load_muplugin_textdomain($domain, $mu_plugin_rel_path); ?>%%%

Examples

This example assumes that the plugin's .mo files are placed in a 'lang' folder in your plugin's directory. If the locale is set to 'es_US', WordPress will attempt to load 'my-plugin-es_US.mo' from the 'lang' directory.

add_action( 'plugins_loaded', 'myplugin_muload_textdomain' );
function myplugin_muload_textdomain() {
	load_muplugin_textdomain( 'my-plugin', basename( dirname(__FILE__) ) . '/lang' );
}

Change Log

Source File

load_muplugin_textdomain() is located in onlyincludecodewp-includes/l10n.php/code/onlyinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Template Description

Link to the source code on http://core.trac.wordpress.org/browser/.

Parameters

  1. filename
  2. (option) path to codetag/code (version) or codetrunk/code. This option is only used for a new function.br /Default: codetrunk/code -- trunk is the latest bleeding edge development version of WordPress.

Usage

Link to the stable version: pre检查到模板循环:模板:Trac/pre

Link to trunk: pre检查到模板循环:模板:Trac/pre

/div

wordpress.org.cn.