Filter hook 'wp_opcache_invalidate_file'

in WP Core File wp-admin/includes/file.php at line 2763

View Source

wp_opcache_invalidate_file

Filter Hook
Description
Filters whether to invalidate a file from the opcode cache.

Hook Information

File Location wp-admin/includes/file.php View on GitHub
Hook Type Filter
Line Number 2763

Hook Parameters

Type Name Description
bool $will_invalidate Whether WordPress will invalidate `$filepath`. Default true.
string $filepath The path to the PHP file to invalidate.

Usage Examples

Basic Usage
<?php
// Hook into wp_opcache_invalidate_file
add_filter('wp_opcache_invalidate_file', 'my_custom_filter', 10, 2);

function my_custom_filter($will_invalidate, $filepath) {
    // Your custom filtering logic here
    return $will_invalidate;
}

Source Code Context

wp-admin/includes/file.php:2763 - How this hook is used in WordPress core
<?php
2758  	 * @since 5.5.0
2759  	 *
2760  	 * @param bool   $will_invalidate Whether WordPress will invalidate `$filepath`. Default true.
2761  	 * @param string $filepath        The path to the PHP file to invalidate.
2762  	 */
2763  	if ( apply_filters( 'wp_opcache_invalidate_file', true, $filepath ) ) {
2764  		return opcache_invalidate( $filepath, $force );
2765  	}
2766  
2767  	return false;
2768  }

PHP Documentation

<?php
/**
	 * Filters whether to invalidate a file from the opcode cache.
	 *
	 * @since 5.5.0
	 *
	 * @param bool   $will_invalidate Whether WordPress will invalidate `$filepath`. Default true.
	 * @param string $filepath        The path to the PHP file to invalidate.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-admin/includes/file.php
Related Hooks

Related hooks will be displayed here in future updates.