You are here

function simplenews_token_info in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 simplenews.tokens.inc \simplenews_token_info()
  2. 8 simplenews.tokens.inc \simplenews_token_info()
  3. 7.2 simplenews.tokens.inc \simplenews_token_info()
  4. 7 simplenews.tokens.inc \simplenews_token_info()

Implements hook_token_info().

File

./simplenews.tokens.inc, line 15
Token related hook implementations.

Code

function simplenews_token_info() {
  $types['simplenews-subscriber'] = [
    'name' => t('Simplenews subscriber'),
    'description' => t('Tokens related to the newsletter recipient'),
    'needs-data' => 'simplenews_subscriber',
  ];
  $types['simplenews-newsletter'] = [
    'name' => t('Simplenews newsletter'),
    'description' => t('Tokens related to the newsletter'),
    'needs-data' => 'newsletter',
  ];

  // Tokens for simplenews subscriber.
  $subscriber['subscribe-url'] = [
    'name' => t('Subscription URL'),
    'description' => t('The URL of the page where the subscription is confirmed.'),
  ];
  $subscriber['unsubscribe-url'] = [
    'name' => t('Unsubscribe URL'),
    'description' => t('The URL of the page where the cancellation of the subscription is confirmed.'),
  ];
  $subscriber['manage-url'] = [
    'name' => t('Manage URL'),
    'description' => t('The URL of the page where the subscribers can manage their newsletter subscriptions.'),
  ];
  $subscriber['combined-url'] = [
    'name' => t('Combined confirmation URL'),
    'description' => t('The URL of the page where subscribers can confirm their subscription changes.'),
  ];
  $subscriber['mail'] = [
    'name' => t('Subscriber email'),
    'description' => t('The email address of the newsletter receiver.'),
  ];
  $subscriber['user'] = [
    'name' => t('Corresponding user'),
    'description' => t('The user object that corresponds to this subscriber. This is not set for anonymous subscribers.'),
    'type' => 'user',
  ];

  // Tokens for simplenews newsletter.
  $newsletter['name'] = [
    'name' => t('Newsletter'),
    'description' => t('The name of the newsletter.'),
  ];
  $newsletter['url'] = [
    'name' => t('Newsletter URL'),
    'description' => t('The URL of the page listing the issues of this newsletter.'),
  ];
  return [
    'types' => $types,
    'tokens' => [
      'simplenews-subscriber' => $subscriber,
      'simplenews-newsletter' => $newsletter,
    ],
  ];
}