'', 'enabled' => true, 'name' => __( 'Notification', 'chargeforms' ), 'send_to_type' => 'fixed', // fixed | field 'send_to_field' => '', 'email' => '', 'cc' => '', 'bcc' => '', 'subject' => '', 'message' => '', 'attach_uploads' => false, 'condition_enabled' => false, 'condition_match' => 'all', 'condition_rules' => [], 'routing_field' => '', 'routing_rules' => [], // [ ['value' => ..., 'email' => ...], ... ] ]; } /** @return array List of notification rows — real ones from settings['notifications'] if present, else a single synthesized legacy row. Never empty. */ public static function from_settings( array $settings ) { if ( ! empty( $settings['notifications'] ) && is_array( $settings['notifications'] ) ) { return array_map( fn( $row ) => wp_parse_args( is_array( $row ) ? $row : [], self::defaults() ), array_values( $settings['notifications'] ) ); } return [ wp_parse_args( [ 'id' => 'legacy', 'name' => __( 'Admin Notification Email', 'chargeforms' ), 'send_to_type' => $settings['notification_send_to_type'] ?? 'fixed', 'send_to_field' => $settings['notification_send_to_field'] ?? '', 'email' => $settings['notification_email'] ?? '', 'cc' => $settings['notification_cc'] ?? '', 'bcc' => $settings['notification_bcc'] ?? '', 'subject' => $settings['notification_subject'] ?? '', 'message' => $settings['notification_message'] ?? '', 'attach_uploads' => ! empty( $settings['notification_attach_uploads'] ), ], self::defaults() ) ]; } public static function find( array $settings, $id ) { foreach ( self::from_settings( $settings ) as $row ) { if ( $row['id'] === $id ) { return $row; } } return null; } public static function new_id() { return 'ntf_' . wp_generate_password( 12, false, false ); } }