PATH:
home
/
centosnipponia
/
public_html
/
nipponiacom
/
wp-content
/
themes
/
sydney-pro-ii
/
inc
/
integrations
<?php /** * Mailchimp related functions * * @package Sydney */ /** * Get Mailchimp lists */ function sydney_get_mailchimp_lists() { $api_key = get_theme_mod( 'mailchimp_api_key', '' ); $lists = array(); if ( empty( $api_key ) ) { return $lists; } $response = wp_remote_get('https://' . substr($api_key, strpos($api_key, '-') + 1) . '.api.mailchimp.com/3.0/lists/?fields=lists.id,lists.name&count=1000', [ 'headers' => [ 'Content-Type' => 'application/json', 'Authorization' => 'Basic ' . base64_encode('user:' . $api_key), ], ]); if (!is_wp_error($response)) { $response = json_decode(wp_remote_retrieve_body($response)); if (!empty($response) && !empty($response->lists)) { $lists[''] = __( 'Select list', 'sydney' ); for ($i = 0; $i < count($response->lists); $i++) { $lists[$response->lists[$i]->id] = $response->lists[$i]->name; } } } return $lists; } /** * Subscribe to Mailchimp */ function sydney_mailchimp_subscribe() { $api_key = get_theme_mod( 'mailchimp_api_key', '' ); if ( empty( $api_key ) ) { wp_send_json_error( __( 'Mailchimp API key is not set', 'sydney' ) ); } if ( !isset($_POST['fields'] ) ) { return; } $fields = $_POST['fields']; $list_id = $_POST['listId']; parse_str($_POST['fields'], $settings); $merge_fields = array( 'FNAME' => !empty($settings['sydney-mailchimp-fname']) ? $settings['sydney-mailchimp-fname'] : '', 'LNAME' => !empty($settings['sydney-mailchimp-lname']) ? $settings['sydney-mailchimp-lname'] : '', ); $body_params = array( 'email_address' => $settings['sydney-mailchimp-email'], 'status' => 'subscribed', 'merge_fields' => $merge_fields, ); $response = wp_remote_post( 'https://' . substr($api_key, strpos( $api_key, '-' ) + 1) . '.api.mailchimp.com/3.0/lists/' . $list_id . '/members/' . md5(strtolower($settings['sydney-mailchimp-email'])), [ 'method' => 'PUT', 'headers' => [ 'Content-Type' => 'application/json', 'Authorization' => 'Basic ' . base64_encode('user:' . $api_key), ], 'body' => json_encode( $body_params ), ] ); if (!is_wp_error($response)) { $response = json_decode(wp_remote_retrieve_body($response)); if (!empty($response)) { if ($response->status == 'subscribed') { wp_send_json([ 'status' => 'subscribed', ]); } else { wp_send_json([ 'status' => $response->title, ]); } } } } add_action('wp_ajax_mailchimp_subscribe', 'sydney_mailchimp_subscribe' ); add_action('wp_ajax_nopriv_mailchimp_subscribe', 'sydney_mailchimp_subscribe' );
[+]
..
[+]
elementor
[+]
learndash
[+]
learnpress
[+]
lifter
[+]
wpml
[-] class-sydney-amp.php
[edit]
[-] class-sydney-elementor-adobe-fonts.php
[edit]
[-] class-sydney-maxmegamenu.php
[edit]
[-] mailchimp.php
[edit]
[-] .htaccess.disabled
[edit]