Gravity_Forms\Gravity_Forms\Settings\Settings
Source: includes/settings/class-settings.php:16
Details
- Kind:
class - Namespace:
Gravity_Forms\Gravity_Forms\Settings
Properties
| Property | Type | Description |
|---|---|---|
$input_name_prefix | string | Input field name prefix. |
$capability | string | Capability required for saving settings. |
$fields | array | Settings fields. |
$is_tabbed | bool | Flags whether settings display in tabs. |
$before_fields | callable | HTML to be rendered before displaying fields. |
$after_fields | callable | HTML to be rendered after displaying fields. |
$current_form | integer | The current form being modified by the settings. |
$save_button | array | Primary Save button to be displayed in header. |
$postback_message_callback | callable | Determines validation message should be displayed. |
Methods
| Method | Description |
|---|---|
__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
| Name | Type | Default | Description |
|---|---|---|---|
$args | array | [] |
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
| Name | Type | Default | Description |
|---|---|---|---|
$scripts | array | Array 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
| Name | Type | Default | Description |
|---|---|---|---|
$styles | array | Array 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
| Name | Type | Default | Description |
|---|---|---|---|
$addon | \GFAddOn | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$tab | array | Tab 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
| Name | Type | Default | Description |
|---|---|---|---|
$section | array | Section properties. |
Since: 2.5
Source: includes/settings/class-settings.php:760
render_field()
public function render_field( $field )
Render a single field.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field | Fields\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
| Name | Type | Default | Description |
|---|---|---|---|
$html | string | '' | 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
| Name | Type | Default | Description |
|---|---|---|---|
$dependency | string | array | callable | null | Condition 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
| Name | Type | Default | Description |
|---|---|---|---|
$dependency | string | array | callable | null | Condition 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
| Name | Type | Default | Description |
|---|---|---|---|
$props | array | Fields\Base | Field/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
| Name | Type | Default | Description |
|---|---|---|---|
$section | array | Settings 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
| Name | Type | Default | Description |
|---|---|---|---|
$values | array | Posted 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
| Name | Type | Default | Description |
|---|---|---|---|
$values | array | Posted 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
| Name | Type | Default | Description |
|---|---|---|---|
$type | string | Field type to search for. | |
$groups | array | bool | false | Array 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
| Name | Type | Default | Description |
|---|---|---|---|
$values | array | Posted 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
| Name | Type | Default | Description |
|---|---|---|---|
$name | string | Name of field to insert before/after. | |
$fields | array | Fields\Base[] | Field(s) to add. | |
$position | string | Insert field "before" or "after" existing field. | |
$groups | array | false | false | Array 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
| Name | Type | Default | Description |
|---|---|---|---|
$name | string | Name of field to remove. | |
$groups | array | false | false | Array 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
| Name | Type | Default | Description |
|---|---|---|---|
$name | string | Name of field to replace. | |
$fields | array | Fields\Base[] | Field(s) to replace. | |
$groups | array | false | false | Array 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
| Name | Type | Default | Description |
|---|---|---|---|
$name | string | Name of field to retrieve. | |
$groups | array | bool | false | Array 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
| Name | Type | Default | Description |
|---|---|---|---|
$type | string | Field type to search for. | |
$groups | array | bool | false | Array 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
| Name | Type | Default | Description |
|---|---|---|---|
$fields | array | [] | 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
| Name | Type | Default | Description |
|---|---|---|---|
$input_name_prefix | string | '_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