Skip to content

Metatavu/wordpress-lyyti

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wordpress integration for Lyyti

Instalation

Download latest release zip-file from https://github.com/Metatavu/wordpress-lyyti/releases and unzip the file into Wordpress /wp-content/plugins -folder.

After that activate the plugin via 'Plugins' menu from Wordpress administration view.

Configuration

Plugin can be configured via Wordpress admin menu Settings > Lyyti Settings.

API Settings

These settings specify how the plugin connects to the API.

  • API URL - URL into Lyyti API (e.g. https://api.lyyti.com/v2)
  • Public Key - Public API key (e.g. apitesti)
  • Private Key - Private API key (e.g. asdasdasd123)

Usage

lyyti-list-events

You can use lyyti-list-events -shortcode for listing event's from Lyyti. Shortcode should be placed inside page content in Wordpress.

You can use following options:

  • event_id: string If omitted, all authorized events are returned.
  • category: integer Only list events with a category ID that matches this parameter (including any sub-categories of the given category).
  • start_time: timestamp OR (now, yearstart, yearend) This filter can be for example "123456" (exact second), "-123456" (before, inclusive), "123456-" (after, inclusive) or "1230-1240" (range, inclusive). You can use words now, yearstart or yearend instead of timestamps. Filter now uses current timestamp, yearstart filter uses timestamp of first day of the current year and yearend filter uses timestamp of last day of the current year.
  • end_time: timestamp OR (now, yearstart, yearend) This filter can be for example "123456" (exact second), "-123456" (before, inclusive), "123456-" (after, inclusive) or "1230-1240" (range, inclusive). You can use words now, yearstart or yearend instead of timestamps. Filter now uses current timestamp, yearstart filter uses timestamp of first day of the current year and yearend filter uses timestamp of last day of the current year.
  • enrollment_open: timestamp This filter can be for example "123456" (exact second), "-123456" (before, inclusive), "123456-" (after, inclusive) or "1230-1240" (range, inclusive).
  • enrollment_deadline: timestamp This filter can be for example "123456" (exact second), "-123456" (before, inclusive), "123456-" (after, inclusive) or "1230-1240" (range, inclusive).
  • canceling_deadline: timestamp This filter can be for example "123456" (exact second), "-123456" (before, inclusive), "123456-" (after, inclusive) or "1230-1240" (range, inclusive).
  • editing_deadline: timestamp This filter can be for example "123456" (exact second), "-123456" (before, inclusive), "123456-" (after, inclusive) or "1230-1240" (range, inclusive).
  • hide_custom_field_options: integer All event custom field options are included in every event for legacy reasons. When requesting a lot of events, this parameter sholid probably be set to 1, to hide the options. All custom field information can be found from the event_custom_fields resource.
  • custom_field_id: integer Filter in events for which this custom event field has been answered
  • custom_field_answer: integer Filter in events for which this particliar answer has been given to a custom field (NOTE: Also requires custom_field_id)
  • archived: boolean Filter archived events in or out from the query by setting this parameter to 1 or 0.
  • participant_count: integer The number of reserved participants.
  • participant_capacity: integer The maximum participant capacity, empty if none is set.

Example:

[lyyti-list-events archived=0]

Customization

By default plugin renders very basic event list but you can customize the how the list is rendered by adding lyyti/events.php into you theme.

For example adding following contents into your theme's lyyti/events.php -file, plugin would render only name and enrolment link for all listed events:

<?php
  function getLocalizedLyytiProperty($property, $locales) {
    foreach ($locales as $locale) {
      if (!empty($property[$locale])) {
        return $property[$locale];
      }
    }

    return '';
  }

  $locales = ["en", "fi"];

  foreach ($data->events as $event) {
    $eventName = getLocalizedLyytiProperty($event["name"], $locales);
    $enrollmentUrl = $event["enrollment_url"];

    echo sprintf('<div>%s', $eventName);
    if (!empty($enrollmentUrl)) {
      echo sprintf(' <a target="_blank" href="%s">Enroll</a>', $enrollmentUrl);
    }

    echo "</div>";
  }
?>