| 1 |
<?php |
| 2 |
/** |
| 3 |
* MailChimp ↔ Form Builder: enable field type + publish cached lists to the editor. |
| 4 |
*/ |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 7 |
|
| 8 |
// Loaded via wppb_fb_load_addon_integrations(); do not include directly. |
| 9 |
|
| 10 |
wppb_fb_register_subscribe_bridge( array( |
| 11 |
'field_type' => 'MailChimp Subscribe', |
| 12 |
'bridge_key' => 'mailchimp', |
| 13 |
'settings_url' => admin_url( 'admin.php?page=profile-builder-mailchimp' ), |
| 14 |
'lists' => 'wppb_in_mci_fb_get_lists', |
| 15 |
) ); |
| 16 |
|
| 17 |
/** |
| 18 |
* MailChimp lists for the editor selector. |
| 19 |
* |
| 20 |
* @return array[] `[ { value, label } ]` |
| 21 |
*/ |
| 22 |
function wppb_in_mci_fb_get_lists() { |
| 23 |
$settings = get_option( 'wppb_mci_settings' ); |
| 24 |
$valid = get_option( 'wppb_mailchimp_api_key_validated', false ); |
| 25 |
|
| 26 |
$lists = array(); |
| 27 |
if ( $valid && ! empty( $settings['lists'] ) && is_array( $settings['lists'] ) ) { |
| 28 |
foreach ( $settings['lists'] as $list_id => $list ) { |
| 29 |
$lists[] = array( |
| 30 |
'value' => (string) $list_id, |
| 31 |
'label' => isset( $list['name'] ) ? $list['name'] : (string) $list_id, |
| 32 |
); |
| 33 |
} |
| 34 |
} |
| 35 |
return $lists; |
| 36 |
} |
| 37 |
|