* WooCommerce Admin Unsecured Files Note.
* Adds a warning about potentially unsecured files.
namespace Automattic\WooCommerce\Internal\Admin\Notes;
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\Notes\Note;
if ( ! class_exists( Note::class ) ) {
class_alias( WC_Admin_Note::class, Note::class );
class UnsecuredReportFiles {
* Name of the note for use in the database.
const NOTE_NAME = 'wc-admin-remove-unsecured-report-files';
public static function get_note() {
$note->set_title( __( 'Potentially unsecured files were found in your uploads directory', 'woocommerce' ) );
/* translators: 1: opening analytics docs link tag. 2: closing link tag */
__( 'Files that may contain %1$sstore analytics%2$s reports were found in your uploads directory - we recommend assessing and deleting any such files.', 'woocommerce' ),
'<a href="https://woocommerce.com/document/woocommerce-analytics/" target="_blank">',
$note->set_content_data( (object) array() );
$note->set_type( Note::E_WC_ADMIN_NOTE_ERROR );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-admin' );
__( 'Learn more', 'woocommerce' ),
'https://developer.woocommerce.com/2021/09/22/important-security-patch-released-in-woocommerce/',
Note::E_WC_ADMIN_NOTE_UNACTIONED,
__( 'Dismiss', 'woocommerce' ),
Note::E_WC_ADMIN_NOTE_ACTIONED,
* Add the note if it passes predefined conditions.
public static function possibly_add_note() {
$note = self::get_note();
if ( self::note_exists() ) {
* Check if the note has been previously added.
public static function note_exists() {
$data_store = \WC_Data_Store::load( 'admin-note' );
$note_ids = $data_store->get_notes_with_name( self::NOTE_NAME );
return ! empty( $note_ids );