Last active
May 10, 2021 16:44
-
-
Save angelcosta/cc002522b798da61c5c1a6ca4bdbb34f to your computer and use it in GitHub Desktop.
MailerLite - Subscribers counter
This file contains 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
//Add this to your functions.php then use the shortcode [assinantes] to show your list numbers | |
function assinantes_madmimi() { | |
$transient = get_transient( 'assinantes_madmimi' ); | |
if( ! empty( $transient ) ) { | |
return $transient; | |
} else { | |
$username = "your email at madmimi"; | |
$apikey = "your api key"; | |
$response = wp_remote_retrieve_body( wp_remote_get( "https://api.madmimi.com/audience_members.json?username=$username&api_key=$apikey" ) ); | |
$json = json_decode( $response, true ); | |
$assinantes = number_format($json[count], '0',',','.'); | |
set_transient( 'assinantes_madmimi', $assinantes, HOUR_IN_SECONDS ); | |
return $assinantes; | |
} | |
} | |
add_shortcode( 'assinantes', 'assinantes_madmimi' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment