is_active() ) { $properties += array( 'wpc_airtable' => array(), ); } return $properties; } /** * Saves the wpc_airtable property value. * * @param WPCF7_ContactForm $contact_form A WPCF7_ContactForm instance. * @see 'wpcf7_save_contact_form' action hook */ function save_contact_form( $contact_form ) { $service = WPCF7_Airtable_Service::get_instance(); if ( ! $service->is_active() ) { return; } // Nonce checked by WPCF7 {@see wpcf7_load_contact_form_admin}. $prop = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing $prop['enabled'] = isset( $_POST['wpc-wpcf7-airtable']['enabled'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing $prop['app_id_selected'] = isset( $_POST['wpc-wpcf7-airtable']['app_id_selected'] ) ? sanitize_text_field( wp_unslash( $_POST['wpc-wpcf7-airtable']['app_id_selected'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing $prop['table_selected'] = isset( $_POST['wpc-wpcf7-airtable']['table_selected'] ) ? sanitize_text_field( wp_unslash( $_POST['wpc-wpcf7-airtable']['table_selected'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing $prop['mapping'] = isset( $_POST['wpc-wpcf7-airtable']['mapping'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['wpc-wpcf7-airtable']['mapping'] ) ) : array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing $prop['map_types'] = isset( $_POST['wpc-wpcf7-airtable']['map_types'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['wpc-wpcf7-airtable']['map_types'] ) ) : array(); $contact_form->set_properties( array( 'wpc_airtable' => $prop, ) ); } /** * Builds the editor panel for the wpc_airtable property. * * @param array $panels Contact Form 7 panels. * @see 'wpcf7_editor_panels' filter hook. */ function editor_panels( $panels ) { $service = WPCF7_Airtable_Service::get_instance(); if ( ! $service->is_active() ) { return $panels; } $contact_form = \WPCF7_ContactForm::get_current(); $prop = wp_parse_args( $contact_form->prop( 'wpc_airtable' ), array( 'enabled' => true, 'app_id_selected' => '', 'table_selected' => '', 'mapping' => array(), 'map_types' => array(), ) ); $editor_panel = function () use ( $prop, $service, $contact_form ) { $description = sprintf( /* translators: %s: html link */ esc_html( __( 'You can set up the Airtable integration here. For details, see %s.', 'add-on-cf7-for-airtable' ) ), str_replace( ' admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'my-ajax-nonce' ), 'table_selected' => esc_js( $table_selected ), 'app_id_selected' => esc_js( $app_id_selected ), ); wp_localize_script( 'wpcf7-airtable-js', 'wpconnectWpcf7AirtableAdmin', $script_data ); ?> get_api_key(); ?>
array( 'title' => __( 'Airtable', 'add-on-cf7-for-airtable' ), 'callback' => $editor_panel, ), ); return $panels; }