Skip to content

Commit

Permalink
Merge pull request #76 from humanmade/backport-75-to-v10-branch
Browse files Browse the repository at this point in the history
[Backport v10-branch] Update docs for consent category labels
  • Loading branch information
roborourke authored Feb 9, 2022
2 parents ab20b98 + 76e9be0 commit 48636ef
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "package",
"require": {
"php": ">=7.1",
"altis/consent": "~1.0.9"
"altis/consent": "~1.0.10"
},
"license": "GPL-3.0",
"authors": [
Expand Down
17 changes: 17 additions & 0 deletions docs/consent/filter-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,23 @@ add_filter( 'altis.consent.categories', function( $categories ) {
} );
```

## `altis.consent.category_labels`

The consent categories with labels for end user display.

### Parameters

**`$categories`** _(array)_ The list of consent categories with labels. Defaults are "Functional", "Preferences", "Statistics", "Anonymous statistics" and "Marketing".

### Example
```php
// Changing the 'preferences' category label to 'Settings'.
add_filter( 'altis.consent.category_labels', function( $categories ) {
$categories['preferences'] = __( 'Settings' );
return $categories;
} );
```

## `altis.consent.values`

The possible consent values.
Expand Down
33 changes: 33 additions & 0 deletions docs/consent/function-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,39 @@ wp_localize_script( 'altis-consent', 'altisConsent', [
] );
```

## `consent_category_labels`

Returns a list of consent categories with labels.

* See [`altis.consent.category_labels`](./filter-reference.md#altisconsentcategorylabels)

### Return

_(array)_ The list of currently allowed consent categories. Defaults are "Functional", "Preferences", "Statistics", "Anonymous statistics" and "Marketing".

### Example
```php
wp_localize_script( 'altis-consent', 'altisConsent', [
'labels' => consent_category_labels(),
] );
```

## `get_category_label`

Returns the label for a given consent category.

### Parameters

**`$category`** _(string)_ The category to get the label for.
### Return

_(string)_ The label or an empty string if the `$category` is unknown.

### Example
```php
echo esc_html( Consent\get_category_label( 'preferences' ) );
```

## `consent_values`

Returns a list of active possible consent values.
Expand Down

0 comments on commit 48636ef

Please sign in to comment.