Description
The Plugin Check GitHub Action is failing with the following errors:
Error: unlink() is discouraged. Use wp_delete_file() to delete a file.
Error: unlink() is discouraged. Use wp_delete_file() to delete a file.
Error: Process completed with exit code 1.
The issue is in includes/Abilities/Image/Import_Base64_Image.php where unlink() is being used to clean up temporary files. WordPress coding standards require using wp_delete_file() instead of the native PHP unlink() function.
Affected lines:
- Line 245: Error handling when writing to temp file fails
- Line 279: Cleanup of temp file after
media_handle_sideload()
Step-by-step reproduction instructions
- Push code to any branch that includes
includes/Abilities/Image/Import_Base64_Image.php
- Wait for GitHub Actions to run
- Check the "Plugin Check Plugin" workflow
- Observe the failure with the
unlink() deprecation errors
Code snippet
Line 245:
if ( false === $bytes_written ) {
@unlink( $temp_file ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, Generic.PHP.NoSilencedErrors.Forbidden, WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink
return new WP_Error(
'write_failed',
esc_html__( 'Failed to write image data to temporary file.', 'ai' )
);
}
Line 279:
// Clean up temp file if it still exists.
if ( file_exists( $temp_file ) ) {
@unlink( $temp_file ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, Generic.PHP.NoSilencedErrors.Forbidden, WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink
}
Environment info
- Affected branches:
develop and any branch based on it
The commit 36e080b that added the unlink() call belongs to the #134 PR that was merged on Dec 12, 2025
The "Plugin Check" GitHub Action was added on #139 that was also merged on Dec 12, 2025
It seems The "Plugin Check" GitHub Action has been failing since then.
Proposed Solution
Replace both unlink() calls with wp_delete_file():
Line 245:
if ( false === $bytes_written ) {
wp_delete_file( $temp_file );
return new WP_Error(
'write_failed',
esc_html__( 'Failed to write image data to temporary file.', 'ai' )
);
}
Line 279:
// Clean up temp file if it still exists.
if ( file_exists( $temp_file ) ) {
wp_delete_file( $temp_file );
}
This change will:
- Comply with WordPress coding standards
- Fix the Plugin Check CI failures
- Remove the need for phpcs:ignore comments on these lines
cc: @dkotter
Description
The Plugin Check GitHub Action is failing with the following errors:
The issue is in
includes/Abilities/Image/Import_Base64_Image.phpwhereunlink()is being used to clean up temporary files. WordPress coding standards require usingwp_delete_file()instead of the native PHPunlink()function.Affected lines:
media_handle_sideload()Step-by-step reproduction instructions
includes/Abilities/Image/Import_Base64_Image.phpunlink()deprecation errorsCode snippet
Line 245:
Line 279:
Environment info
developand any branch based on itThe commit 36e080b that added the
unlink()call belongs to the #134 PR that was merged on Dec 12, 2025The "Plugin Check" GitHub Action was added on #139 that was also merged on Dec 12, 2025
It seems The "Plugin Check" GitHub Action has been failing since then.
Proposed Solution
Replace both
unlink()calls withwp_delete_file():Line 245:
Line 279:
This change will:
cc: @dkotter