Last active
May 10, 2021 16:41
-
-
Save angelcosta/92e0ef31a95c24eddf2dfbf294f9be58 to your computer and use it in GitHub Desktop.
MadMimi - 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 [mmsubscribers] to show your list numbers | |
function subscribers_madmimi() { | |
$transient = get_transient( 'subscribers_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( 'subscribers_madmimi', $subscribers, HOUR_IN_SECONDS ); | |
return $subscribers; | |
} | |
} | |
add_shortcode( 'mmsubscribers', 'subscribers_madmimi' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment