notices[ $slug ] = apply_filters(
'cpsw_notices_add_args',
[
'class' => $class,
'message' => $message,
'dismissible' => $dismissible,
]
);
}
/**
* Display any notices we've collected thus far.
*
* @since 1.2.0
*
* @return void
*/
public function get_notices() {
if ( ! current_user_can( 'manage_woocommerce' ) ) {
return;
}
foreach ( (array) $this->notices as $notice_key => $notice ) {
echo '
';
if ( $notice['dismissible'] ) {
?>
';
echo wp_kses(
$notice['message'],
[
'a' => [
'href' => [],
'target' => [],
],
]
);
echo '
';
}
}
/**
* Hides any notice.
*
* @since 1.2.0
*
* @return void
*/
public function hide() {
if (
! isset( $_GET['_cpsw_stripe_notice_nonce'] )
|| ! wp_verify_nonce( sanitize_text_field( $_GET['_cpsw_stripe_notice_nonce'] ), 'cpsw_stripe_hide_notices_nonce' )
) {
return;
}
$notice = isset( $_GET['cpsw-stripe-hide-notice'] ) ? wc_clean( wp_unslash( $_GET['cpsw-stripe-hide-notice'] ) ) : '';
update_option( 'cpsw_show_' . $notice . '_notice', 'no' );
}
/**
* Check current page is cpsw setting page.
*
* @since 1.2.0
*
* @param string $section gateway section.
*
* @return boolean
*/
public function is_cpsw_section( $section ) {
// This function just determines scope of admin notice, Nonce verification may not be required.
if ( isset( $_GET['page'] ) && 'wc-settings' === sanitize_text_field( $_GET['page'] ) && isset( $_GET['tab'] ) && isset( $_GET['section'] ) && sanitize_text_field( $_GET['section'] ) === $section ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
return true;
}
return false;
}
}