Last active
September 15, 2019 15:05
-
-
Save jrick1229/c16f82a4facf29f8f77d8bf0ff2d186d to your computer and use it in GitHub Desktop.
Check if a subscription is active by displaying an admin notice. (for testing only)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wcs_is_sub_active_notice() { | |
$sub_id = 445; | |
if ( wcs_get_subscription( $sub_id ) ) { | |
if ( wcs_get_subscription( $sub_id )->get_status() == 'active' ) { | |
$class = 'notice notice-error'; | |
$message = __( '445 is ACTIVE', 'sample-text-domain' ); | |
printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) ); | |
} else { | |
$class = 'notice notice-error'; | |
$message = __( '445 is NOT-ACTIVE', 'sample-text-domain' ); | |
printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) ); | |
} | |
} else { | |
$class = 'notice notice-error'; | |
$message = __( 'NULL', 'sample-text-domain' ); | |
printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) ); | |
} | |
} | |
add_action( 'admin_notices', 'wcs_is_sub_active_notice' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment