Attempts to clear the opcode cache for a directory of files.
Description
See also
Parameters
$dir
stringrequired- The path to the directory for which the opcode cache is to be cleared.
Source
return opcache_invalidate( $filepath, $force );
}
return false;
}
/**
* Attempts to clear the opcode cache for a directory of files.
*
* @since 6.2.0
*
* @see wp_opcache_invalidate()
* @link https://www.php.net/manual/en/function.opcache-invalidate.php
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @param string $dir The path to the directory for which the opcode cache is to be cleared.
*/
function wp_opcache_invalidate_directory( $dir ) {
global $wp_filesystem;
if ( ! is_string( $dir ) || '' === trim( $dir ) ) {
if ( WP_DEBUG ) {
$error_message = sprintf(
/* translators: %s: The function name. */
__( '%s expects a non-empty string.' ),
'<code>wp_opcache_invalidate_directory()</code>'
);
wp_trigger_error( '', $error_message );
}
return;
}
$dirlist = $wp_filesystem->dirlist( $dir, false, true );
if ( empty( $dirlist ) ) {
return;
}
/*
* Recursively invalidate opcache of files in a directory.
*
* WP_Filesystem_*::dirlist() returns an array of file and directory information.
*
* This does not include a path to the file or directory.
* To invalidate files within sub-directories, recursion is needed
* to prepend an absolute path containing the sub-directory's name.
*
Changelog
Version | Description |
---|---|
6.2.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.