class-wc-payments-notes-set-https-for-checkout.php
1.68 KB
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
<?php
/**
* Set up ensure https on checkout note for WooCommerce inbox.
*
* @package WooCommerce\Payments\Admin
*/
use Automattic\WooCommerce\Admin\Notes\Note;
use Automattic\WooCommerce\Admin\Notes\NoteTraits;
defined( 'ABSPATH' ) || exit;
/**
* Class WC_Payments_Notes_Set_Https_For_Checkout
*/
class WC_Payments_Notes_Set_Https_For_Checkout {
use NoteTraits {
can_be_added as protected trait_can_be_added;
}
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-payments-notes-set-https-for-checkout';
/**
* Name of the note for use in the database.
*/
const NOTE_DOCUMENTATION_URL = 'https://woocommerce.com/document/ssl-and-https/#section-7';
/**
* Checks if a note can and should be added.
*
* @return bool
*/
public static function can_be_added() {
// This note only makes sense if HTTPS is not enforced yet.
if ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) || wc_site_is_https() ) {
return false;
}
return self::trait_can_be_added();
}
/**
* Get the note.
*/
public static function get_note() {
$note = new Note();
$note->set_title( __( 'Enable secure checkout', 'woocommerce-payments' ) );
$note->set_content( __( 'Enable HTTPS on your checkout pages to display all available payment methods and protect your customers data.', 'woocommerce-payments' ) );
$note->set_content_data( (object) [] );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-payments' );
$note->add_action(
self::NOTE_NAME,
__( 'Read more', 'woocommerce-payments' ),
self::NOTE_DOCUMENTATION_URL,
'unactioned',
true
);
return $note;
}
}