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(); ?>
WP Connect logo


scan_form_tags() as $tag ) { if ( empty( $tag->name ) ) { continue; } ?> name; $selected_column_name = ''; $mapped_class = ''; $mapped_text = $tag_name; $mapped_error_desc = ''; $selected_column_type = ''; if ( isset( $mapped_tags[ $tag_name ] ) && in_array( $mapped_tags[ $tag_name ]['airtable_field_name'], $available_columns_name, true ) ) { $selected_column_name = $mapped_tags[ $tag_name ]['airtable_field_name']; $selected_column_type = $mapped_tags[ $tag_name ]['airtable_field_type']; $mapped_class = 'is-mapped'; /* translators: %s: tag name */ $mapped_text = sprintf( __( '%s: mapped', 'add-on-cf7-for-airtable' ), $tag_name ); } if ( ! empty( $selected_column_name ) ) { $mapped_columns[] = $selected_column_name; } // Reverse the types keys (the last one should be the default one), get labels from get_airtable_fields_types. $normalized_tag_type = Helpers\normalize_cf7_field_type( $tag->basetype ); $options_keys = array_flip( array_reverse( $field_mapper->get_field_compatible_airtable_types( $normalized_tag_type, Helpers\tag_has_multiple_value( $tag ) ) ) ); $options_labels = array_intersect_key( $field_mapper->get_airtable_fields_types(), $options_keys ); $options = array_merge( $options_keys, $options_labels ); $has_available_mapping = count( $options ) > 0; ?> '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo Helpers\generate_airtable_fields_select( $app_id_selected, $table_selected, $tag_name, $mappings_selected ); echo ''; } ?>
', esc_attr( $tag_name ) ); $i = 0; foreach ( $options as $option_value => $option_text ) { printf( '', esc_attr( $option_value ), ( ! empty( $selected_column_type ) ? ( $selected_column_type === $option_value ? 'selected="selected"' : '' ) : ( ! $i ? 'selected="selected"' : '' ) ), esc_html( $option_text ) ); ++$i; } printf( '' ); } ?>
0 && count( $unmapped_columns_name ) > 0 ) { ?>

' . esc_html( implode( ', ', $unmapped_columns_name ) ); ?>

array( 'title' => __( 'Airtable', 'add-on-cf7-for-airtable' ), 'callback' => $editor_panel, ), ); return $panels; }