render();
self::page_footer();
}
/**
* Prepare form settings fields.
*
* @since 2.5
* @since 2.9.8 Updated honeypotAction default to spam.
* @since 2.9.21 Moved the honeypot fields to a new spam section and added submission speed check fields.
* @since 2.10.0 Added the enableSpamConfirmation toggle to the spam section.
*
* @param array $form Form being edited.
*
* @return array
*/
public static function form_settings_fields( $form ) {
// Handles the deprecation notice for the confirmation ready classes in the CSS class field of form settings.
$deprecated_confirmation_classes_field_notice = function ( $value, $field ) use ( $form ) {
if ( GFCommon::is_legacy_markup_enabled_og( $form ) ) {
return false;
}
$deprecated_confirmation_classes = [
'gf_confirmation_simple_yellow',
'gf_confirmation_simple_gray',
'gf_confirmation_yellow_gradient',
'gf_confirmation_green_gradient',
];
if ( in_array( $value, $deprecated_confirmation_classes ) ) {
return '
';
return $html;
},
),
),
);
}
/**
* Filters the form settings fields before they are displayed.
*
* @since 2.5
*
* @param array $fields Form settings fields.
* @param array $form Form Object.
*/
$fields = gf_apply_filters( array( 'gform_form_settings_fields', rgar( $form, 'id' ) ), $fields, $form );
return $fields;
}
/**
* The Settings API runs the settings field method before processing the postback,
* so we have to run this hack to ensure we're respecting the posted value on initial load.
*
* @todo - Remove this and fix the Settings API order-of-operations.
*
* @since 3.0.0
*
* @param array $form The form to check.
*
* @return bool
*/
public static function legacy_markup_enabled_or_posted( $form ) {
if ( $_POST && empty( $_POST['_gform_setting_markupVersion'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing,
return apply_filters( 'gform_show_legacy_markup_setting', false );
}
return apply_filters( 'gform_show_legacy_markup_setting', GFCommon::is_legacy_markup_enabled( $form ) );
}
/**
* Determine whether to show the legacy markup setting.
*
* @since 2.7.15
*
* @return bool
*/
public static function show_legacy_markup_setting() {
$show_legacy_setting = true;
if ( version_compare( get_option( 'rg_form_original_version', '1.0' ), '2.7.14.2', '>=' ) && ! self::legacy_is_in_use() ) {
$show_legacy_setting = false;
}
// if this is a new install, and if there are no forms with legacy markup enabled, do not show the legacy markup setting
return apply_filters( 'gform_show_legacy_markup_setting', $show_legacy_setting );
}
/**
* Check whether any forms on this site use legacy markup.
*
* @since 2.7.15
*
* @return bool
*/
public static function legacy_is_in_use() {
$legacy_is_in_use = GFCache::get( 'legacy_is_in_use', $found_in_cache );
if ( ! $found_in_cache ) {
$legacy_is_in_use = GFFormsModel::has_legacy_markup();
GFCache::set( 'legacy_is_in_use', $legacy_is_in_use, true, DAY_IN_SECONDS );
}
return $legacy_is_in_use;
}
/**
* Get the warning for the legacy markup field.
*
* @since 2.7.15
*
* @return string
*/
public static function legacy_markup_warning() {
return '
' . esc_html__( 'Legacy markup is incompatible with many new features, including the Orbital Theme.', 'gravityforms' ) . '
' . esc_html__( 'Legacy markup will be removed in Gravity Forms 4.0, and then all forms will use modern markup. We recommend using modern markup on all forms.', 'gravityforms' ) . '
';
}
/**
* Displays a warning if confirmation deprecated CSS Ready Classes are used in the form settings.
*
* This method checks if the form uses any deprecated CSS Ready Classes and displays
* a warning message. It also ensures the warning is not shown if the user has dismissed it.
*
* @since 2.9.15
*
* @param array $form The form object being checked for deprecated classes.
*
* @return string|false The HTML for the warning message or false if no warning is needed.
*/
public static function deprecated_classes_warning( $form ) {
if ( GFCommon::is_legacy_markup_enabled_og( $form ) ){
return false;
}
$deprecated_confirmation_classes = [
'gf_confirmation_simple_yellow',
'gf_confirmation_simple_gray',
'gf_confirmation_yellow_gradient',
'gf_confirmation_green_gradient',
];
if ( isset( $form['cssClass'] ) ) {
$field_classes = explode( ' ', $form['cssClass'] );
foreach ( $field_classes as $class ) {
if ( in_array( $class, $deprecated_confirmation_classes ) ) {
return '
' . esc_html__( 'This form uses a deprecated CSS Ready Class, which will be removed in Gravity Forms 4.0.', 'gravityforms' ) . '