is_active() ) { $properties += array( 'sendinblue' => array(), ); } return $properties; } add_action( 'wpcf7_save_contact_form', 'wpcf7_sendinblue_save_contact_form', 10, 3 ); /** * Saves the sendinblue property value. */ function wpcf7_sendinblue_save_contact_form( $contact_form, $args, $context ) { $service = WPCF7_Sendinblue::get_instance(); if ( ! $service->is_active() ) { return; } $prop = (array) ( $_POST['wpcf7-sendinblue'] ?? array() ); $prop = wp_parse_args( $prop, array( 'enable_contact_list' => false, 'contact_lists' => array(), 'enable_transactional_email' => false, 'email_template' => 0, ) ); $prop['contact_lists'] = array_map( 'absint', $prop['contact_lists'] ); $prop['email_template'] = absint( $prop['email_template'] ); $contact_form->set_properties( array( 'sendinblue' => $prop, ) ); } add_filter( 'wpcf7_editor_panels', 'wpcf7_sendinblue_editor_panels', 10, 1 ); /** * Builds the editor panel for the sendinblue property. */ function wpcf7_sendinblue_editor_panels( $panels ) { $service = WPCF7_Sendinblue::get_instance(); if ( ! $service->is_active() ) { return $panels; } $contact_form = WPCF7_ContactForm::get_current(); $prop = wp_parse_args( $contact_form->prop( 'sendinblue' ), array( 'enable_contact_list' => false, 'contact_lists' => array(), 'enable_transactional_email' => false, 'email_template' => 0, ) ); $editor_panel = static function () use ( $prop, $service ) { $description = sprintf( esc_html( __( "You can set up the Brevo integration here. For details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ), __( 'Brevo integration', 'contact-form-7' ) ) ); $lists = wpcf7_sendinblue_get_lists(); $templates = $service->get_templates(); ?>

array( 'title' => __( 'Brevo', 'contact-form-7' ), 'callback' => $editor_panel, ), ); return $panels; } /** * Retrieves contact lists from Brevo's database. */ function wpcf7_sendinblue_get_lists() { static $lists = array(); $service = WPCF7_Sendinblue::get_instance(); if ( ! empty( $lists ) or ! $service->is_active() ) { return $lists; } $limit = 50; $offset = 0; while ( count( $lists ) < $limit * 10 ) { $lists_next = (array) $service->get_lists( array( 'limit' => $limit, 'offset' => $offset, ) ); if ( ! empty( $lists_next ) ) { $lists = array_merge( $lists, $lists_next ); } if ( count( $lists_next ) < $limit ) { break; } $offset += $limit; } return $lists; }