$new_field; } } /** * Preserve addon field. * * @since 1.9.5 * * @param string $slug Addon slug. * @param array $new_field Previous form fields settings. * @param array $previous_field Form fields settings. * * @return void */ private function preserve_addon_field_settings( string $slug, array &$new_field, array $previous_field ): void { $prefix = $this->prepare_prefix( $slug ); $changed_settings = array_diff_key( $previous_field, $new_field ); $preserve_fields = self::FIELD_OPTIONS[ $slug ] ?? []; foreach ( $changed_settings as $setting_name => $setting_value ) { if ( strpos( $setting_name, $prefix ) === 0 || in_array( $setting_name, $preserve_fields, true ) ) { $new_field[ $setting_name ] = $setting_value; } } if ( ! empty( $preserve_fields['choices'] ) && is_array( $preserve_fields['choices'] ) && ! empty( $new_field['choices'] ) && is_array( $new_field['choices'] ) ) { $this->preserve_addon_field_choices_settings( $preserve_fields['choices'], $new_field, $previous_field ); } } /** * Preserve addon field choices settings. * * @since 1.9.9 * * @param array $choice_settings Choice settings. * @param array $new_field Previous form fields settings. * @param array $previous_field Form fields settings. * * @return void */ private function preserve_addon_field_choices_settings( array $choice_settings, array &$new_field, array $previous_field ): void { if ( ! isset( $previous_field['choices'] ) || ! is_array( $previous_field['choices'] ) ) { return; } $previous_choices = $previous_field['choices']; foreach ( $new_field['choices'] as $choice_id => $choice ) { foreach ( $choice_settings as $setting_name ) { if ( isset( $previous_choices[ $choice_id ][ $setting_name ] ) ) { $new_field['choices'][ $choice_id ][ $setting_name ] = $previous_choices[ $choice_id ][ $setting_name ]; } } } } /** * Preserve addon panel. * * @since 1.9.3 * * @param string $slug Addon slug. * @param array $form_data Form data. * @param array $previous_form_data Previous form data. */ private function preserve_addon_panel( string $slug, array &$form_data, array $previous_form_data ): void { $panel = $this->prepare_prefix( $slug ); // The addon settings stored its own panel, e.g., $form_data[lead_forms], $form_data[webhooks], etc. if ( ! empty( $previous_form_data[ $panel ] ) ) { $form_data[ $panel ] = $previous_form_data[ $panel ]; } } /** * Preserve addon settings stored inside the settings panel with a specific prefix. * e.g. $form_data[settings][{$prefix}_enabled], $form_data[settings][{$prefix}_email], etc. * * @since 1.9.4 * * @param string $slug Addon option prefix. * @param array $new_settings Form settings. * @param array $previous_settings Previous form settings. */ private function preserve_addon_settings( string $slug, array &$new_settings, array $previous_settings ): void { $prefix = $this->prepare_prefix( $slug ); static $legacy_options = [ 'offline_forms' => [ 'offline_form' ], 'user_registration' => [ 'user_login_hide', 'user_reset_hide' ], 'surveys_polls' => [ 'survey_enable', 'poll_enable' ], ]; // BC: User Registration addon has `registration_` prefix instead of `user_registration`. if ( $prefix === 'user_registration' ) { $prefix = 'registration'; } foreach ( $previous_settings as $setting_name => $value ) { if ( strpos( $setting_name, $prefix ) === 0 ) { $new_settings[ $setting_name ] = $value; continue; } // BC: The options don't have a prefix and hard-coded in the `$legacy_options` variable. if ( isset( $legacy_options[ $prefix ] ) && in_array( $setting_name, $legacy_options[ $prefix ], true ) ) { $new_settings[ $setting_name ] = $value; } } } /** * Preserve addon notifications. * * @since 1.9.4 * * @param string $slug Addon slug. * @param array $new_notifications List of form notifications. * @param array $previous_notifications Previously saved list of form notifications. * * @return void */ private function preserve_addon_notifications( string $slug, array &$new_notifications, array $previous_notifications ): void { $prefix = $this->prepare_prefix( $slug ); foreach ( $previous_notifications as $notification_id => $notification_settings ) { if ( empty( $new_notifications[ $notification_id ] ) ) { continue; } $changed_notification_settings = array_diff_key( $notification_settings, $new_notifications[ $notification_id ] ); foreach ( $changed_notification_settings as $setting_name => $value ) { if ( strpos( $setting_name, $prefix ) === 0 ) { $new_notifications[ $notification_id ][ $setting_name ] = $value; } } } } /** * Preserve Providers that are not active. * * @since 1.9.4 * * @param array $form_data Form data. * @param array $previous_form_data Previous form data. */ private function preserve_providers( array &$form_data, array $previous_form_data ): void { if ( empty( $previous_form_data['providers'] ) ) { return; } $active_providers = wpforms_get_providers_available(); foreach ( $previous_form_data['providers'] as $slug => $provider ) { if ( ! empty( $active_providers[ $slug ] ) ) { continue; } $form_data['providers'][ $slug ] = $provider; } } /** * Preserve Payments providers that are not active. * * @since 1.9.4 * * @param array $form_data Form data. * @param array $previous_form_data Previous form data. */ private function preserve_payments( array &$form_data, array $previous_form_data ): void { if ( empty( $previous_form_data['payments'] ) ) { return; } foreach ( $previous_form_data['payments'] as $slug => $value ) { if ( ! empty( $form_data['payments'][ $slug ] ) ) { continue; } $form_data['payments'][ $slug ] = $value; } } /** * Convert slug to a addon prefix. * * @since 1.9.4 * * @param string $slug Addon slug. * * @return string */ private function prepare_prefix( string $slug ): string { return str_replace( '-', '_', $slug ); } } 'rest/class-bwfan-compatibility-with-security-by-cleantalk.php' => defined( 'SPBC_VERSION' ), 'rest/class-bwfan-compatibility-with-tec.php' => class_exists( 'Tribe__Events__Main' ), 'rest/class-bwfan-compatibility-with-hostinger-reach.php' => class_exists( 'Hostinger\Reach\Jobs\ActionScheduler' ), // other files 'class-bwfan-compatibility-with-wp-oauth.php' => ( defined( 'WPOAUTH_VERSION' ) && class_exists( 'WO_SERVER' ) ), ]; self::add_files( array_filter( $compatibilities ) ); } /** * Include valid compatibility files * * @param array $paths */ public static function add_files( $paths ) { /** Compatibilities folder */ $dir = plugin_dir_path( BWFAN_PLUGIN_FILE ) . 'compatibilities'; try { foreach ( $paths as $file => $condition ) { include_once $dir . '/' . $file; } } catch ( Exception|Error $e ) { BWF_Logger::get_instance()->log( 'Error while loading compatibility files: ' . $e->getMessage(), 'compatibilities-load-error', 'fka-files-load-error' ); } } } add_action( 'plugins_loaded', array( 'BWFAN_Compatibilities', 'load_all_compatibilities' ), 999 ); Cabinet IMPACT CROISSANCE
Logo IC (BG sombre)

Notre site est en reconstruction

Nous travaillons à faire de cette plateforme un canal efficace de renforcement de la compétitivité de votre entreprise. 


Le site sera de nouveau accessible dans 

Compte à Rebours
00
jours
00
heures
00
minutes
00
secondes