Skip to main content

Gravity_Forms\Gravity_Forms\Settings\Settings

Source: includes/settings/class-settings.php:16

Details​

  • Kind: class
  • Namespace: Gravity_Forms\Gravity_Forms\Settings

Properties​

PropertyTypeDescription
$input_name_prefixstringInput field name prefix.
$capabilitystringCapability required for saving settings.
$fieldsarraySettings fields.
$is_tabbedboolFlags whether settings display in tabs.
$before_fieldscallableHTML to be rendered before displaying fields.
$after_fieldscallableHTML to be rendered after displaying fields.
$current_formintegerThe current form being modified by the settings.
$save_buttonarrayPrimary Save button to be displayed in header.
$postback_message_callbackcallableDetermines validation message should be displayed.

Methods​

MethodDescription
__construct()Initialize Settings instance.
action_admin_enqueue_scripts()Enqueue registered scripts and styles.
styles()Registered styles to enqueue when displaying settings.
scripts()Registered scripts to enqueue when displaying settings.
filter_gform_noconflict_scripts()Registers enqueued scripts to the no-conflict scripts whitelist.
filter_gform_noconflict_styles()Registers enqueued styles to the no-conflict styles whitelist.
render()Render fields.
render_tab_navigation()Render tab navigation above settings sections.
render_tab()Render a single tab of fields.
render_section()Render a single section of fields.
render_field()Render a single field.
render_save_button()Display Save button in page header.
get_save_success_message()Returns message to display when settings have been successfully saved.
get_save_error_message()Returns message to display when settings could not be saved.
is_dependency_met()Determines if the conditions to display a field or section have been met.
is_legacy_dependency_met()Determines if the conditions to display a field or section have been met.
maybe_get_tooltip()Returns the markup for a tooltip, if provided.
has_card_layout()Determine whether a section gets a card layout.
process_postback()Processes the save settings callback.
set_save_message_after_redirect()Set the save success message after a save redirect.
current_user_has_access()Check if the current user has the capabilities to access these settings.
filter_values()Filter posted field values.
save_values()Save posted values.
has_field_type()Check if defined fields contain a specific field type.
validate()Validate settings fields.
get_field_errors()Get errors for all fields.
get_active_tab()Get the tab currently being displayed.
get_current_form()Get the current form object.
get_current_form_id()Get the current form ID.
add_field()Add a field to existing defined fields.
remove_field()Remove a field from existing defined fields.
replace_field()Replace an existing defined field.
get_field()Get a specific settings field.
get_fields_by_type()Returns fields of a specific field type.
get_fields()Get registered settings fields.
set_fields()Define fields to be rendered.
get_input_name_prefix()Returns the input name prefix.
set_input_name_prefix()Set the input name prefix.
get_current_values()Returns the current field values.
get_previous_values()Get previous field values.
get_posted_values()Returns posted field values.
get_value()Get current value for field.
set_values()Save current field values.
set_previous_values()Save previous field values.
get_save_callback()Get the save callback.
set_save_callback()Set the save callback.
set_postback_message_callback()Set the postback message callback.
is_save_postback()Determines if Save button was pressed.
remove_has_published_posts_from_api_user_query()Remove the "has published posts" query from the REST user query.

Method Reference​

__construct()​

public function __construct( $args=[] )

Initialize Settings instance.

Parameters​

NameTypeDefaultDescription
$argsarray[]

Since: 2.5

Source: includes/settings/class-settings.php:169

action_admin_enqueue_scripts()​

public function action_admin_enqueue_scripts()

Enqueue registered scripts and styles.

Since: 2.5

Source: includes/settings/class-settings.php:251

styles()​

public function styles()

Registered styles to enqueue when displaying settings.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:319

scripts()​

public function scripts()

Registered scripts to enqueue when displaying settings.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:341

filter_gform_noconflict_scripts()​

public function filter_gform_noconflict_scripts( $scripts )

Registers enqueued scripts to the no-conflict scripts whitelist.

Parameters​

NameTypeDefaultDescription
$scriptsarrayArray of scripts to be whitelisted.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:551

filter_gform_noconflict_styles()​

public function filter_gform_noconflict_styles( $styles )

Registers enqueued styles to the no-conflict styles whitelist.

Parameters​

NameTypeDefaultDescription
$stylesarrayArray of styles to be whitelisted.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:566

render()​

public function render()

Render fields.

Handles enqueueing styles, processing postback.

Parameters​

NameTypeDefaultDescription
$addon\GFAddOnThe Add-On responsible for rendering the settings page.

Since: 2.5

Source: includes/settings/class-settings.php:583

render_tab_navigation()​

public function render_tab_navigation()

Render tab navigation above settings sections.

Since: 2.5

Source: includes/settings/class-settings.php:678

render_tab()​

public function render_tab( $tab )

Render a single tab of fields.

Parameters​

NameTypeDefaultDescription
$tabarrayTab properties.

Since: 2.5

Source: includes/settings/class-settings.php:730

render_section()​

public function render_section( $section )

Render a single section of fields.

Parameters​

NameTypeDefaultDescription
$sectionarraySection properties.

Since: 2.5

Source: includes/settings/class-settings.php:760

render_field()​

public function render_field( $field )

Render a single field.

Parameters​

NameTypeDefaultDescription
$fieldFields\Base

Since: 2.5

Source: includes/settings/class-settings.php:873

render_save_button()​

public function render_save_button( $html='' )

Display Save button in page header.

Parameters​

NameTypeDefaultDescription
$htmlstring''Existing Save button HTML.

Returns​

  • string

Since: 2.5

Source: includes/settings/class-settings.php:940

get_save_success_message()​

public function get_save_success_message()

Returns message to display when settings have been successfully saved.

Returns​

  • string

Since: 2.5

Source: includes/settings/class-settings.php:1235

get_save_error_message()​

public function get_save_error_message()

Returns message to display when settings could not be saved.

Returns​

  • string

Since: 2.5

Source: includes/settings/class-settings.php:1250

is_dependency_met()​

public function is_dependency_met( $dependency )

Determines if the conditions to display a field or section have been met.

Parameters​

NameTypeDefaultDescription
$dependencystring | array | callable | nullCondition to be met.

Returns​

  • bool

Since: 2.5

Source: includes/settings/class-settings.php:1300

is_legacy_dependency_met()​

public function is_legacy_dependency_met( $dependency )

Determines if the conditions to display a field or section have been met.

Handles legacy dependencies for pre-Gravity Forms 2.5.

Parameters​

NameTypeDefaultDescription
$dependencystring | array | callable | nullCondition to be met.

Returns​

  • bool

Since: 2.5

Source: includes/settings/class-settings.php:1408

maybe_get_tooltip()​

public static function maybe_get_tooltip( $props )

Returns the markup for a tooltip, if provided.

Parameters​

NameTypeDefaultDescription
$propsarray | Fields\BaseField/Choice properties.

Returns​

  • string

Since: 2.5

Source: includes/settings/class-settings.php:1471

has_card_layout()​

public function has_card_layout( $section )

Determine whether a section gets a card layout.

If a section has one field, and the field type is card, it gets the card layout.

Parameters​

NameTypeDefaultDescription
$sectionarraySettings section

Returns​

  • bool

Since: 2.5.7

Source: includes/settings/class-settings.php:1503

process_postback()​

public function process_postback()

Processes the save settings callback.

Validates values. If valid, filters and saves values. If invalid, displays error message.

Since: 2.5

Source: includes/settings/class-settings.php:1532

set_save_message_after_redirect()​

public function set_save_message_after_redirect()

Set the save success message after a save redirect.

Since: 2.5

Source: includes/settings/class-settings.php:1597

current_user_has_access()​

public function current_user_has_access()

Check if the current user has the capabilities to access these settings.

Returns​

  • bool

Since: 2.5

Source: includes/settings/class-settings.php:1608

filter_values()​

public function filter_values( $values )

Filter posted field values.

Runs save_callback when defined for field.

Parameters​

NameTypeDefaultDescription
$valuesarrayPosted field values.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:1622

save_values()​

public function save_values( $values )

Save posted values.

Parameters​

NameTypeDefaultDescription
$valuesarrayPosted values.

Since: 2.5

Source: includes/settings/class-settings.php:1721

has_field_type()​

public function has_field_type( $type, $groups=false )

Check if defined fields contain a specific field type.

Parameters​

NameTypeDefaultDescription
$typestringField type to search for.
$groupsarray | boolfalseArray of tabs or sections to search through. Defaults to defined fields.

Returns​

  • bool

Since: 2.5

Source: includes/settings/class-settings.php:1750

validate()​

public function validate( $values )

Validate settings fields.

Fields can be invalid when marked as required and have a blank value or fails a custom validation check. Use the validation_callback field property to implement a custom validation check.

Parameters​

NameTypeDefaultDescription
$valuesarrayPosted field values.

Returns​

  • bool

Since: 2.5

Source: includes/settings/class-settings.php:1805

get_field_errors()​

public function get_field_errors()

Get errors for all fields.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:1882

get_active_tab()​

public function get_active_tab()

Get the tab currently being displayed.

Returns​

  • bool | string

Since: 2.5

Source: includes/settings/class-settings.php:1960

get_current_form()​

public function get_current_form()

Get the current form object.

Returns​

  • bool | array

Since: 2.5

Source: includes/settings/class-settings.php:2000

get_current_form_id()​

public function get_current_form_id()

Get the current form ID.

Returns​

  • bool | int

Since: 2.5

Source: includes/settings/class-settings.php:2038

add_field()​

public function add_field( $name, $fields, $position, $groups=false )

Add a field to existing defined fields.

Parameters​

NameTypeDefaultDescription
$namestringName of field to insert before/after.
$fieldsarray | Fields\Base[]Field(s) to add.
$positionstringInsert field "before" or "after" existing field.
$groupsarray | falsefalseArray of sections/fields.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:2059

remove_field()​

public function remove_field( $name, $groups=false )

Remove a field from existing defined fields.

Parameters​

NameTypeDefaultDescription
$namestringName of field to remove.
$groupsarray | falsefalseArray of sections/fields.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:2140

replace_field()​

public function replace_field( $name, $fields, $groups=false )

Replace an existing defined field.

Parameters​

NameTypeDefaultDescription
$namestringName of field to replace.
$fieldsarray | Fields\Base[]Field(s) to replace.
$groupsarray | falsefalseArray of sections/fields.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:2209

get_field()​

public function get_field( $name, $groups=false )

Get a specific settings field.

Parameters​

NameTypeDefaultDescription
$namestringName of field to retrieve.
$groupsarray | boolfalseArray of tabs or sections to search through. Defaults to defined fields.

Returns​

  • Fields\Base | bool

Since: 2.5

Source: includes/settings/class-settings.php:2286

get_fields_by_type()​

public function get_fields_by_type( $type, $groups=false )

Returns fields of a specific field type.

Parameters​

NameTypeDefaultDescription
$typestringField type to search for.
$groupsarray | boolfalseArray of tabs or sections to search through. Defaults to defined fields.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:2339

get_fields()​

public function get_fields()

Get registered settings fields.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:2386

set_fields()​

public function set_fields( $fields=[] )

Define fields to be rendered.

Parameters​

NameTypeDefaultDescription
$fieldsarray[]Array of settings fields.

Since: 2.5

Source: includes/settings/class-settings.php:2399

get_input_name_prefix()​

public function get_input_name_prefix()

Returns the input name prefix.

Returns​

  • string

Since: 2.5

Source: includes/settings/class-settings.php:2499

set_input_name_prefix()​

public function set_input_name_prefix( $input_name_prefix='_gform_setting' )

Set the input name prefix.

Parameters​

NameTypeDefaultDescription
$input_name_prefixstring'_gform_setting'Input name prefix.

Since: 2.5

Source: includes/settings/class-settings.php:2512

get_current_values()​

public function get_current_values()

Returns the current field values.

If this is a postback request, returns posted values. Otherwise, returns saved values passed in to constructor.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:2527

get_previous_values()​

public function get_previous_values()

Get previous field values.

Returns​

  • bool | array

Since: 2.5

Source: includes/settings/class-settings.php:2548

get_posted_values()​

public function get_posted_values()

Returns posted field values.

Returns​

  • array

Since: 2.5

Source: includes/settings/class-settings.php:2561

get_value()​

public function get_value( $name, $default_value='', $values=false )

Get current value for field.

Use default value if not found.

Parameters​

NameTypeDefaultDescription
$namestringField name.
$default_valuestring''Default value.
$valuesarray | boolfalseCurrent field values.

Returns​

  • bool | array | string

Since: 2.5

Source: includes/settings/class-settings.php:2604

set_values()​

public function set_values( $values=[] )

Save current field values.

Parameters​

NameTypeDefaultDescription
$valuesarray | string[]Field values to be saved.

Since: 2.5

Source: includes/settings/class-settings.php:2682

set_previous_values()​

public function set_previous_values( $values=[] )

Save previous field values.

Parameters​

NameTypeDefaultDescription
$valuesarray[]Field values to be saved.

Since: 2.5

Source: includes/settings/class-settings.php:2703

get_save_callback()​

public function get_save_callback()

Get the save callback.

Returns​

  • string | callable

Since: 2.5

Source: includes/settings/class-settings.php:2716

set_save_callback()​

public function set_save_callback( $callback='' )

Set the save callback.

Parameters​

NameTypeDefaultDescription
$callbackstring | callable''Option name or callable function values will be saved to.

Since: 2.5

Deprecated: 2.6.1

Source: includes/settings/class-settings.php:2730

set_postback_message_callback()​

public function set_postback_message_callback( $callback )

Set the postback message callback.

Parameters​

NameTypeDefaultDescription
$callbackcallableCallable function to use when displaying success message.

Returns​

Since: 2.5

Source: includes/settings/class-settings.php:2759

is_save_postback()​

public static function is_save_postback()

Determines if Save button was pressed.

Returns​

  • bool

Since: 2.5

Source: includes/settings/class-settings.php:2781

remove_has_published_posts_from_api_user_query()​

public function remove_has_published_posts_from_api_user_query( $prepared_args, $request )

Remove the "has published posts" query from the REST user query.

This will make sure that the User Select field can find all users, not just users with published posts.

Parameters​

NameTypeDefaultDescription
$prepared_argsarrayThe prepared arguments for the REST user query.
$request\WP_REST_RequestThe current REST request.

Returns​

  • array — The modified prepared arguments for the REST user query.

Since: 2.9.5

Source: includes/settings/class-settings.php:2799