Skip to main content

GravityKit\GravityView\Settings\ViewSettings

The View Settings class.

Since:

  • 2.0
  • 3.0.0 (Migrated to GravityKit\GravityView\Settings namespace.)

Source: src/Settings/ViewSettings.php:20

Details​

  • Kind: class
  • Namespace: GravityKit\GravityView\Settings
  • Extends: Settings

Methods​

MethodDescription
declares_array_value()Whether a registered View setting declares that it holds an array.
with_defaults()Retrieve an instance of the settings with default values.
defaults()Retrieve the default View settings.
validate_url_with_tags()Validates URLs with merge tags.

Method Reference​

declares_array_value()​

public static function declares_array_value( $setting ): bool

Whether a registered View setting declares that it holds an array.

checkboxes settings post one key per choice, and any setting may declare an array default; everything else is treated as scalar. A custom setting type that posts one input per choice must therefore declare an array default, and be registered during save requests (not only while rendering its own admin screen), or its value is rejected on write.

Both write paths consult this: the classic post.php save via ViewStyles::sanitize_payload(), and the Abilities/REST write via InspectorRoute::validate_template_setting_value().

Parameters​

NameTypeDefaultDescription
$settingmixedRegistered setting definition, or null when the key is not registered.

Returns​

  • bool

Since: 3.3.2

Source: src/Settings/ViewSettings.php:41

with_defaults()​

public static function with_defaults( $detailed=false )

Retrieve an instance of the settings with default values.

Parameters​

NameTypeDefaultDescription
$detailedboolfalseWhether to return detailed setting meta information or just the value.

Returns​

  • \GV\View_Settings

Since: 2.0

Source: src/Settings/ViewSettings.php:63

defaults()​

public static function defaults( $detailed=false, $group=null )

Retrieve the default View settings.

Parameters​

NameTypeDefaultDescription
$detailedboolfalseWhether to return detailed setting meta information or just the value.
$groupstringnullRetrieve settings of a particular group.

Returns​

  • array — { The default settings along with their values.

Since: 2.0

Source: src/Settings/ViewSettings.php:91

validate_url_with_tags()​

public static function validate_url_with_tags()

Validates URLs with merge tags.

Valid format examples: http://foo.bar/{field:1} https://foo.bar/{field:1} https://{field:1} https://foo.bar/{field:1}/{another:2} https://foo.bar/{field:1}:8080?name=value#fragment http://foo.bar https://foo.bar/path/to/resource http://192.168.0.1:8080/query?name=value#fragment https://[2001:db8::1]:443/resource https://2001:0db8:85a3:0000:0000:8a2e:0370:7334/path/to?name=value#fragment {field:1} {field:1}/path/to?name=value#fragment

Invalid examples: htp://foo.bar - Misspelled protocol http (should not match). foo.bar - Missing protocol (http:// or https://) or leading //. https://foo - Incomplete domain (e.g., .com). http://foo - Same as above; incomplete domain. foo.bar/{field:1} - Missing protocol (http:// or https://) or leading //. foo - No protocol, domain, or valid structure.

Returns​

  • array

Since:

  • 2.33
  • 3.10.0 (Made public so feature modules can reuse the rule set.)

Source: src/Settings/ViewSettings.php:744