WP_Translation_Controller::unload_file()
Unloads a translation file for a given text domain.
Метод класса: WP_Translation_Controller{}
Хуков нет.
Возвращает
true|false
. True on success, false otherwise.
Использование
$WP_Translation_Controller = new WP_Translation_Controller(); $WP_Translation_Controller->unload_file( $file, $textdomain, ?string $locale ): bool;
- $file(WP_Translation_File|строка) (обязательный)
- Translation file instance or file name.
- $textdomain(строка)
- Text domain.
По умолчанию: 'default' - ?string $locale **
- -
По умолчанию: null
Список изменений
С версии 6.5.0 | Введена. |
Код WP_Translation_Controller::unload_file() WP Translation Controller::unload file WP 6.6.2
public function unload_file( $file, string $textdomain = 'default', ?string $locale = null ): bool { if ( is_string( $file ) ) { $file = realpath( $file ); } if ( null !== $locale ) { if ( isset( $this->loaded_translations[ $locale ][ $textdomain ] ) ) { foreach ( $this->loaded_translations[ $locale ][ $textdomain ] as $i => $moe ) { if ( $file === $moe || $file === $moe->get_file() ) { unset( $this->loaded_translations[ $locale ][ $textdomain ][ $i ] ); unset( $this->loaded_files[ $moe->get_file() ][ $locale ][ $textdomain ] ); return true; } } } return true; } foreach ( $this->loaded_translations as $l => $domains ) { if ( ! isset( $domains[ $textdomain ] ) ) { continue; } foreach ( $domains[ $textdomain ] as $i => $moe ) { if ( $file === $moe || $file === $moe->get_file() ) { unset( $this->loaded_translations[ $l ][ $textdomain ][ $i ] ); unset( $this->loaded_files[ $moe->get_file() ][ $l ][ $textdomain ] ); return true; } } } return false; }