Skip to content

Commit

Permalink
Merge pull request #272 from infinum/feature/docs
Browse files Browse the repository at this point in the history
docs
  • Loading branch information
iruzevic authored Sep 25, 2023
2 parents 81ff12b + 8bc5f2d commit 6cba993
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
8 changes: 8 additions & 0 deletions website/forms/features/country-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: country-list
title: Country list
---

*Coming soon*

![Country list screen](/img/forms/country.webp)
60 changes: 60 additions & 0 deletions website/forms/php/helpers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
id: helpers
title: Helpers
---

Eightshift Forms offers static helpers that can be implemented in your project. The key difference between these helpers and filters is that you can use the former in your theme or plugin code regardless of the load cycle.

### esFormsGetFormIdByName

This function retrieves the custom, unique name of a form, as set in the Form settings, from the provided form ID. It's useful when applying specific settings to one or more forms using filters in your project.

Form identification by name (instead of the default "by ID"), can be useful if switching environments when the form ID could change.

```php
if (\function_exists('esFormsGetFormIdByName')) {
echo esFormsGetFormIdByName('<form-id>');
}
```

### esFormsDecryptor

This helper provides decrypt and encrypt methods for variations set in the Form settings, passed to the "Thank you" page after form submission.

```php
if (\function_exists('esFormsDecryptor')) {
$variation = isset($_GET['es-variation']) ? \esFormsDecryptor(\sanitize_text_field(\wp_unslash($_GET['es-variation']))) : '';
}
```

### esFormsGeolocationCountriesList

This method generates a list of countries available in the geolocation API and country fields.

```php
if (\function_exists('esFormsGeolocationCountriesList')) {
$countriesList = esFormsGeolocationCountriesList();
}
```

### esFormsGetSelectOptionsArrayFromString

This helper parses the block grammar output (that the Gutenberg editor generates) for block options, making it easy to use them in your projects.

```php
if (\function_exists('esFormsGetSelectOptionsArrayFromString')) {
$select = esFormsGetSelectOptionsArrayFromString('<options>');
}
```

### esFormsGetComponentsRender

This helper allows you to access the Eightshift Forms component `render` method, enabling you to utilize all Forms components in your projects. If you already have a style set for the selected component, you can use this helper to render it with all the necessary data and styling applied.

A list of all components can be found [here](https://github.com/infinum/eightshift-forms/tree/develop/src/Blocks/components).

```php
if (\function_exists('esFormsGetComponentsRender')) {
$render = esFormsGetComponentsRender('<component>', '[<attributes>]');
}
```
2 changes: 2 additions & 0 deletions website/sidebars-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = {
'features/import-export',
'features/migrations',
'features/cloudflare',
'features/country-list',
],
],
},
Expand Down Expand Up @@ -80,6 +81,7 @@ module.exports = {
},
]
},
'php/helpers',
{
'type': 'category',
'label': 'Filters',
Expand Down
Binary file added website/static/img/forms/country.webp
Binary file not shown.

0 comments on commit 6cba993

Please sign in to comment.