Skip to content

Instantly share code, notes, and snippets.

@angelcosta
Last active May 10, 2021 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelcosta/cc002522b798da61c5c1a6ca4bdbb34f to your computer and use it in GitHub Desktop.
Save angelcosta/cc002522b798da61c5c1a6ca4bdbb34f to your computer and use it in GitHub Desktop.
MailerLite - Subscribers counter
//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