本文整理汇总了PHP中wp_get_pomo_file_data函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_pomo_file_data函数的具体用法?PHP wp_get_pomo_file_data怎么用?PHP wp_get_pomo_file_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_pomo_file_data函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_get_installed_translations
/**
* Get installed translations.
*
* Looks in the wp-content/languages directory for translations of
* plugins or themes.
*
* @since 3.7.0
*
* @param string $type What to search for. Accepts 'plugins', 'themes', 'core'.
* @return array Array of language data.
*/
function wp_get_installed_translations($type)
{
if ($type !== 'themes' && $type !== 'plugins' && $type !== 'core') {
return array();
}
$dir = 'core' === $type ? '' : "/{$type}";
if (!is_dir(WP_LANG_DIR)) {
return array();
}
if ($dir && !is_dir(WP_LANG_DIR . $dir)) {
return array();
}
$files = scandir(WP_LANG_DIR . $dir);
if (!$files) {
return array();
}
$language_data = array();
foreach ($files as $file) {
if ('.' === $file[0] || is_dir(WP_LANG_DIR . "{$dir}/{$file}")) {
continue;
}
if (substr($file, -3) !== '.po') {
continue;
}
if (!preg_match('/(?:(.+)-)?([a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?).po/', $file, $match)) {
continue;
}
if (!in_array(substr($file, 0, -3) . '.mo', $files)) {
continue;
}
list(, $textdomain, $language) = $match;
if ('' === $textdomain) {
$textdomain = 'default';
}
$language_data[$textdomain][$language] = wp_get_pomo_file_data(WP_LANG_DIR . "{$dir}/{$file}");
}
return $language_data;
}
示例2: test_wp_get_pomo_file_data
/**
* @ticket 35284
*/
function test_wp_get_pomo_file_data()
{
$file = DIR_TESTDATA . '/pomo/empty.po';
$array = wp_get_pomo_file_data($file);
$this->assertArrayHasKey('POT-Creation-Date', $array);
$this->assertArrayHasKey('PO-Revision-Date', $array);
$this->assertArrayHasKey('Project-Id-Version', $array);
$this->assertArrayHasKey('X-Generator', $array);
$file = DIR_TESTDATA . '/pomo/mo.pot';
$array = wp_get_pomo_file_data($file);
$this->assertNotEmpty($array['POT-Creation-Date']);
$this->assertNotEmpty($array['PO-Revision-Date']);
$this->assertNotEmpty($array['Project-Id-Version']);
$this->assertArrayHasKey('X-Generator', $array);
$file = DIR_TESTDATA . '/languages/es_ES.po';
$array = wp_get_pomo_file_data($file);
$this->assertArrayHasKey('POT-Creation-Date', $array);
$this->assertNotEmpty($array['PO-Revision-Date']);
$this->assertNotEmpty($array['Project-Id-Version']);
$this->assertNotEmpty($array['X-Generator']);
}