file_mod_allowedfilter-hookWP 4.8.0

Allows you to disable modifications to any part of the code, such as plugin, theme, or core updates.

Usage

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)
Whether file modifications are allowed.
Default: The inverse value of DISALLOW_FILE_MODS
$context(string)

The check context. It can be:

download_language_pack
can_install_language_pack
automatic_updater
capability_edit_themes
capability_update_core
can_install_language_pack

Examples

#1 Disable automatic updates

add_filter( 'file_mod_allowed', 'disallow_plugin_updates', 10, 2 );

function disallow_plugin_updates( $allowed, $context ){

	if( 'automatic_updater' === $context ){
		return false;
	}

	return $allowed;
}

Changelog

Since 4.8.0 Introduced.

Where the hook is called

wp_is_file_mod_allowed()
file_mod_allowed
wp-includes/load.php 1838
return apply_filters( 'file_mod_allowed', ! defined( 'DISALLOW_FILE_MODS' ) || ! DISALLOW_FILE_MODS, $context );

Where the hook is used in WordPress

Usage not found.