array( 'label' => __( 'Name', 'dealroot' ) ), 'email' => array( 'label' => __( 'Email', 'dealroot' ), 'type' => 'email', ), 'phone' => array( 'label' => __( 'Phone', 'dealroot' ), 'type' => 'tel', ), ); } foreach ( $inputs as $key => $input ) { if ( ! isset( $data[ $key ] ) || ( ! is_scalar( $data[ $key ] ) && ! is_array( $data[ $key ] ) ) ) { continue; } $fields[] = array( 'label' => (string) ( $input['label'] ?? $key ), 'name' => (string) $key, 'type' => (string) ( $input['type'] ?? '' ), 'value' => $data[ $key ], ); } $name = (string) ( $data['thrive_leads']['tl_data']['form_name'] ?? '' ); Capture::submission( self::key(), (string) absint( $data['_tcb_id'] ?? 0 ), '' !== $name ? $name : __( 'Thrive form', 'dealroot' ), $fields ); } /** * Fields of a form from its settings: key => label and type. * * @param int $settings_id Form settings ID. * @return array */ private static function inputs( $settings_id ) { $class = '\\TCB\\inc\\helpers\\FormSettings'; if ( ! $settings_id || ! class_exists( $class ) || ! method_exists( $class, 'get_one' ) ) { return array(); } try { $settings = $class::get_one( $settings_id ); $config = is_object( $settings ) && method_exists( $settings, 'get_config' ) ? (array) $settings->get_config( false ) : array(); } catch ( \Throwable $e ) { return array(); } return array_filter( (array) ( $config['inputs'] ?? array() ), 'is_array' ); } }