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
<?php
namespace PaymentPlugins;
defined( 'ABSPATH' ) || exit();
class WC_Stripe_Admin_Notices {
public static function init() {
add_action( 'admin_notices', array( __CLASS__, 'notices' ) );
}
public static function notices() {
$messages = array();
foreach ( static::get_notices() as $key => $notice ) {
if ( $notice['callback']() ) {
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
ob_start();
echo '<div class="notice notice-info woocommerce-message"><p>' . $notice['message']() . '</p></div>';
$message = ob_get_clean();
if ( strstr( $screen_id, 'wc-settings' ) ) {
$messages[] = $message;
} else {
echo $message;
}
}
}
if ( $messages ) {
wp_localize_script( 'wc-stripe-admin-settings', 'wc_stripe_admin_notices', $messages );
}
}
public static function get_notices() {
return array(
'connect_notice' => array(
'callback' => function () {
return ( ! isset( $_GET['_stripe_connect_nonce'] ) &&
( ! stripe_wc()->api_settings->get_option( 'account_id' ) && get_option( 'wc_stripe_connect_notice', 'no' ) == 'yes' ) );
},
'message' => function () {
wp_enqueue_style( 'wc-stripe-styles', stripe_wc()->assets_url( 'css/admin/admin.css' ), array(), stripe_wc()->version() );
return sprintf(
__(
'At Stripe\'s request we have updated how the Stripe for WooCommerce
plugin integrates with Stripe. This new integration offers even more security and
Stripe is requesting that all merchants switch. %1$sUpdate Integration%2$s',
'woo-stripe-payment'
),
' <a href = "' . stripe_wc()->api_settings->get_connect_url() . '" class = "stripe-connect light-blue do-stripe-connect"><span>', '</span></a>'
);
},
),
);
}
}
\PaymentPlugins\WC_Stripe_Admin_Notices::init();