1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
<?php /** * 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 ); }
/** * Unsecured_Report_Files */ class UnsecuredReportFiles {
/** * Name of the note for use in the database. */ const NOTE_NAME = 'wc-admin-remove-unsecured-report-files';
/** * Get the note. * * @return Note|null */ public static function get_note() { $note = new Note(); $note->set_title( __( 'Potentially unsecured files were found in your uploads directory', 'woocommerce' ) ); $note->set_content( sprintf( /* 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">', '</a>' ) ); $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' ); $note->add_action( 'learn-more', __( 'Learn more', 'woocommerce' ), 'https://developer.woocommerce.com/2021/09/22/important-security-patch-released-in-woocommerce/', Note::E_WC_ADMIN_NOTE_UNACTIONED, true ); $note->add_action( 'dismiss', __( 'Dismiss', 'woocommerce' ), wc_admin_url(), Note::E_WC_ADMIN_NOTE_ACTIONED, false );
return $note; }
/** * Add the note if it passes predefined conditions. */ public static function possibly_add_note() { $note = self::get_note();
if ( self::note_exists() ) { return; }
$note->save(); }
/** * 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 ); }
}
|