woocommerce/plugins/woocommerce-admin/src-internal/Admin/Notes/UnsecuredReportFiles.php

89 lines
2.1 KiB
PHP
Raw Normal View History

<?php
/**
* WooCommerce Admin Unsecured Files Note.
*
* Adds a warning about potentially unsecured files.
*/
Make individual note classes internal (https://github.com/woocommerce/woocommerce-admin/pull/8398) * Moved `WooSubscriptionsNotes` * Moved `WooSubscriptionsNotes` deprecated * Moved `WooCommerceSubscriptions` * Moved `WooCommercePayments` * Fix `WooCommerceSubscriptions` * Fix `WooSubscriptionsNotes * Fix `WooCommercePayments` * Moved `WelcomeToWooCommerceForStoreUsers * Add use `Note` * Moved `UpdateStoreDetails` * Moved `UnsecuredReportFiles` * Moved `TrackingOptIn` * Moved `TestCheckout` * Moved `SetUpAdditionalPaymentTypes` * Moved `SellingOnlineCourses` * Moved `RealTimeOrderAlerts` * Moved `PersonalizeStore` * Moved `PerformanceOnMobile` * Moved `PaymentsRemindMeLater` * Moved `OrderMilestones` * Moved `OnlineClothingStore` * Moved `OnboardingPayments * Moved `NewSalesRecord` * Moved `NavigationNudge` * Moved `NavigationNudge` * Moved `MobileApp` * Moved `MigrateFromShopify` * Moved `MarketingJetpack` * Moved `ManageStoreActivityFromHomeScreen` * Moved `ManageOrdersOnTheGo` * Moved `MagentoMigration` * Moved `LaunchChecklist` * Moved `InstallJPAndWCSPlugins` * Moved `InsightFirstSale` * Moved `InsightFirstProductAndPayment` * Moved `GivingFeedbackNotes` * Moved `FirstProduct` * Moved `FirstDownlaodableProduct` * Moved `EUVATNumber` * Moved `EditProductsOnTheMove` * Moved `DeactivatePlugin` * Moved `CustomizingProductCatalog` * Moved `CustomizeStoreWithBlocks` * Moved `CouponPageMoved` * Moved `CompleteStoreDetails` * Moved `ChoosingTheme` * Moved `AddingAndManangingProducts` * Moved `AddFirstProduct` * Removed `OnboardingTraits` trait * Moved `EmailNotification` * Fixed notes * Add changelog * Fix lint error Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2022-03-08 13:55:27 +00:00
namespace Automattic\WooCommerce\Internal\Admin\Notes;
defined( 'ABSPATH' ) || exit;
Make individual note classes internal (https://github.com/woocommerce/woocommerce-admin/pull/8398) * Moved `WooSubscriptionsNotes` * Moved `WooSubscriptionsNotes` deprecated * Moved `WooCommerceSubscriptions` * Moved `WooCommercePayments` * Fix `WooCommerceSubscriptions` * Fix `WooSubscriptionsNotes * Fix `WooCommercePayments` * Moved `WelcomeToWooCommerceForStoreUsers * Add use `Note` * Moved `UpdateStoreDetails` * Moved `UnsecuredReportFiles` * Moved `TrackingOptIn` * Moved `TestCheckout` * Moved `SetUpAdditionalPaymentTypes` * Moved `SellingOnlineCourses` * Moved `RealTimeOrderAlerts` * Moved `PersonalizeStore` * Moved `PerformanceOnMobile` * Moved `PaymentsRemindMeLater` * Moved `OrderMilestones` * Moved `OnlineClothingStore` * Moved `OnboardingPayments * Moved `NewSalesRecord` * Moved `NavigationNudge` * Moved `NavigationNudge` * Moved `MobileApp` * Moved `MigrateFromShopify` * Moved `MarketingJetpack` * Moved `ManageStoreActivityFromHomeScreen` * Moved `ManageOrdersOnTheGo` * Moved `MagentoMigration` * Moved `LaunchChecklist` * Moved `InstallJPAndWCSPlugins` * Moved `InsightFirstSale` * Moved `InsightFirstProductAndPayment` * Moved `GivingFeedbackNotes` * Moved `FirstProduct` * Moved `FirstDownlaodableProduct` * Moved `EUVATNumber` * Moved `EditProductsOnTheMove` * Moved `DeactivatePlugin` * Moved `CustomizingProductCatalog` * Moved `CustomizeStoreWithBlocks` * Moved `CouponPageMoved` * Moved `CompleteStoreDetails` * Moved `ChoosingTheme` * Moved `AddingAndManangingProducts` * Moved `AddFirstProduct` * Removed `OnboardingTraits` trait * Moved `EmailNotification` * Fixed notes * Add changelog * Fix lint error Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
2022-03-08 13:55:27 +00:00
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-admin' ) );
$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-admin' ),
'<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-admin' ),
'https://developer.woocommerce.com/?p=10410',
Note::E_WC_ADMIN_NOTE_UNACTIONED,
true
);
$note->add_action(
'dismiss',
__( 'Dismiss', 'woocommerce-admin' ),
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 );
}
}