| 1 |
<?php |
| 2 |
/** |
| 3 |
* MailPoet ↔ Form Builder: enable field type + publish local lists. |
| 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' => 'MailPoet Subscribe', |
| 12 |
'bridge_key' => 'mailpoet', |
| 13 |
'settings_url' => '', |
| 14 |
'lists' => 'wppb_in_mpi_fb_get_lists', |
| 15 |
) ); |
| 16 |
|
| 17 |
/** |
| 18 |
* MailPoet lists for the editor selector. |
| 19 |
* |
| 20 |
* @return array[] `[ { value, label } ]` |
| 21 |
*/ |
| 22 |
function wppb_in_mpi_fb_get_lists() { |
| 23 |
$lists = array(); |
| 24 |
if ( function_exists( 'wppb_in_mpi_get_lists' ) ) { |
| 25 |
$raw = wppb_in_mpi_get_lists(); |
| 26 |
if ( is_array( $raw ) ) { |
| 27 |
foreach ( $raw as $list ) { |
| 28 |
if ( ! is_array( $list ) ) continue; |
| 29 |
$id = isset( $list['id'] ) ? $list['id'] : ( isset( $list['list_id'] ) ? $list['list_id'] : '' ); |
| 30 |
if ( $id === '' ) continue; |
| 31 |
$lists[] = array( |
| 32 |
'value' => (string) $id, |
| 33 |
'label' => isset( $list['name'] ) ? $list['name'] : (string) $id, |
| 34 |
); |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
return $lists; |
| 39 |
} |
| 40 |
|