file_mod_allowed
Позволяет отключить модификацию любой части код. Например, обновление плагинов, тем, ядра.
Использование
add_filter( 'file_mod_allowed', 'wp_kama_file_mod_allowed_filter', 10, 2 );
/**
* Function for `file_mod_allowed` filter-hook.
*
* @param bool $file_mod_allowed Whether file modifications are allowed.
* @param string $context The usage context.
*
* @return bool
*/
function wp_kama_file_mod_allowed_filter( $file_mod_allowed, $context ){
// filter...
return $file_mod_allowed;
}
- $file_mod_allowed(true|false)
- Разрешены ли модификации файлов.
По умолчанию: Обратное значение DISALLOW_FILE_MODS - $context(строка)
Контекст проверки. Может быть:
download_language_pack can_install_language_pack automatic_updater capability_edit_themes capability_update_core can_install_language_pack
Примеры
#1 Отключим автоматические обновления
add_filter( 'file_mod_allowed', 'disallow_plugin_updates', 10, 2 );
function disallow_plugin_updates( $allowed, $context ){
if( 'automatic_updater' === $context ){
return false;
}
return $allowed;
}
Список изменений
| С версии 4.8.0 | Введена. |
Где вызывается хук
file_mod_allowed
wp-includes/load.php 1836
return apply_filters( 'file_mod_allowed', ! defined( 'DISALLOW_FILE_MODS' ) || ! DISALLOW_FILE_MODS, $context );