Layout Conversion for WP 6.8 / Plugin 6.3 compatibility

Overview

The Widget for Eventbrite API plugin version 6.3+ introduces breaking changes to how event data is accessed in templates for WordPress 6.8 compatibility. Custom templates MUST be updated to use the new data access patterns.

Critical Breaking Changes

❌ REMOVED: Direct Event Access via $data->events->post

The singular $data->events->post is no longer available in templates. This is the most important change that will break existing custom templates.

PHP
// ❌ OLD - NO LONGER WORKS
$title = $data->events->post->post_title;
$id = $data->events->post->ID;
$logo = $data->events->post->logo_url;

✅ NEW: Event Access via Utility Functions

All event data must now be accessed through: 1. Utility functions for common properties 2. $data->utilities->get_event()-> for complex/nested properties

PHP
// ✅ NEW - Utility functions
$title = $data->utilities->get_event_title();
$id = $data->utilities->get_event_ID();
$logo = $data->utilities->get_event_logo_url();

// ✅ NEW - Reference access for nested properties
$width = $data->utilities->get_event()->logo->original->width;
$venue_name = $data->utilities->get_event()->venue->name;

Key Changes

1. Event Data Access Pattern

Before 6.3: – Direct access via $data->events->post – Direct property access like $data->events->post->post_title

After 6.3: – Must use utility functions: $data->utilities->get_event_title() – Or reference access: $data->utilities->get_event()->post_title – Always call $data->utilities->set_event($event) in loops

2. New Utility Functions

The plugin now provides dedicated utility functions for common event properties:

PHP
// Event identification
$data->utilities->get_event_ID()              // Event ID
$data->utilities->get_event_title()           // Event title

// Event images
$data->utilities->get_event_logo_url()        // Logo URL (resized)
$data->utilities->get_event_logo_original_url() // Original logo URL

// Event dates
$data->utilities->get_event_start()           // Start date object
$data->utilities->get_event_end()             // End date object
$data->utilities->get_event_time($args)       // Formatted time string

// Event URLs and attributes
$data->utilities->get_event_eb_url($ext)      // Eventbrite URL
$data->utilities->get_event_classes($args)    // CSS classes
$data->utilities->get_event_attr($attr)       // Generic attribute getter

3. Event Loop Structure

The loop structure remains the same, but event access is different:

PHP
foreach ($data->events->posts as $event) {
    $data->utilities->set_event($event);  // REQUIRED: Set current event
    
    // Now use utility functions or get_event()
    $title = $data->utilities->get_event_title();
    $venue = $data->utilities->get_event()->venue->name;
    
    $data->template_loader->get_template_part('loop_name');
}

Migration Guide for Custom Templates

Step 1: Identify Usage of $data->events->post

Search your custom templates for any usage of $data->events->post (singular). This pattern is completely removed in 6.3+.

Step 2: Replace Direct Event Access

Migration Examples:

PHP
// ❌ OLD: Direct property access via $data->events->post
$title = $data->events->post->post_title;
$content = $data->events->post->post_content;
$id = $data->events->post->ID;
$logo = $data->events->post->logo_url;
$venue_name = $data->events->post->venue->name;

// ✅ NEW: Use utility functions or get_event()
$title = $data->utilities->get_event_title();
$content = $data->utilities->get_event()->post_content;
$id = $data->utilities->get_event_ID();
$logo = $data->utilities->get_event_logo_url();
$venue_name = $data->utilities->get_event()->venue->name;

Step 3: Update Common Patterns

Event Title

PHP
// ❌ OLD
echo $data->events->post->post_title;
the_title_attribute(array('post' => $data->events->post));

// ✅ NEW
echo $data->utilities->get_event_title();
the_title_attribute(array('post' => $data->utilities->get_event()));

Event ID

PHP
// ❌ OLD
$event_id = $data->events->post->ID;

// ✅ NEW
$event_id = $data->utilities->get_event_ID();

Event Logo/Thumbnail

PHP
// ❌ OLD
$logo_url = $data->events->post->logo_url;
$logo_width = $data->events->post->logo->original->width;

// ✅ NEW
$logo_url = $data->utilities->get_event_logo_url();
$logo_width = $data->utilities->get_event()->logo->original->width;

Event Dates

PHP
// ❌ OLD
$start_date = $data->events->post->start;
$end_date = $data->events->post->end;

// ✅ NEW
$start_date = $data->utilities->get_event_start();
$end_date = $data->utilities->get_event_end();

Event Content/Excerpt

PHP
// ❌ OLD
$excerpt = $data->events->post->post_excerpt;
$content = $data->events->post->post_content;

// ✅ NEW
$excerpt = get_the_excerpt($data->utilities->get_event());
$content = $data->utilities->get_event()->post_content;

Venue Information

PHP
// ❌ OLD
$venue_name = $data->events->post->venue->name;
$venue_city = $data->events->post->venue->address->city;

// ✅ NEW
$venue_name = $data->utilities->get_event()->venue->name;
$venue_city = $data->utilities->get_event()->venue->address->city;

Step 4: Update Loop Structure

If your template has custom loops:

PHP
// ❌ OLD - If you were accessing $data->events->post directly
foreach ($data->events->posts as $event) {
    // Trying to use $data->events->post here won't work
    echo $data->events->post->post_title; // BROKEN
}

// ✅ NEW - Must set current event first
foreach ($data->events->posts as $event) {
    $data->utilities->set_event($event);  // REQUIRED
    echo $data->utilities->get_event_title();
}

Quick Reference: When to Use What

  1. Use Utility Functions for:
    • Event ID: get_event_ID()
    • Event Title: get_event_title()
    • Logo URLs: get_event_logo_url(),
      get_event_logo_original_url()
    • Event Dates: get_event_start(),
      get_event_end()
    • Event Time: get_event_time($args)
    • Event URL: get_event_eb_url()
    • CSS Classes: get_event_classes($args)
  2. Use get_event()-> for:
    • Nested properties: ->venue->address->city
    • WordPress functions requiring post object
    • Less common properties not covered by utility functions
    • Complex object access:
      ->organizer->logo->url

Template File Structure

Directory Structure

Markdown
your-theme/
└── widget-for-eventbrite-api/
    ├── layout_custom.php       // Main layout
    ├── loops/
    │   └── loop_custom.php    // Event loop
    └── parts/                 // Reusable parts
        ├── title_widget.php
        └── venue.php

Example Custom Layout

PHP
<?php
// layout_custom.php
$data->event->layout_class = 'wfea-custom';
$data->event->layout_name = 'custom';
?>
<div class="wfea-custom-wrapper">
    <?php $data->template_loader->get_template_part('common'); ?>
</div>

Example Custom Loop

PHP
<?php
// loops/loop_custom.php
?>
<article class="wfea-event <?php echo esc_attr($data->event->classes); ?>">
    <h3><?php echo esc_html($data->utilities->get_event_title()); ?></h3>
    
    <?php if ($data->utilities->get_element('date', $data->args)) : ?>
        <?php $data->template_loader->get_template_part('date_widget'); ?>
    <?php endif; ?>
    
    <?php if ($data->utilities->get_element('excerpt', $data->args)) : ?>
        <div class="wfea-excerpt">
            <?php echo wp_kses_post(get_the_excerpt($data->utilities->get_event())); ?>
        </div>
    <?php endif; ?>
    
    <?php if ($data->utilities->get_element('booknow', $data->args)) : ?>
        <a href="<?php echo esc_url($data->event->booknow); ?>" class="wfea-booknow">
            <?php echo esc_html($data->args['booknow_text']); ?>
        </a>
    <?php endif; ?>
</article>

Critical: WordPress Native Functions

⚠️ NEVER use WordPress native post functions directly on events in templates!

Events are NOT standard WordPress posts. They are custom objects from the Eventbrite API. Using WordPress post functions will cause errors or unexpected behavior.

❌ DO NOT USE:

PHP
// These will NOT work correctly with events:
the_post()
setup_postdata()
get_post()
the_title()
the_content()
the_excerpt()
get_the_ID()
wp_get_attachment_image()

✅ ALWAYS USE Utility Functions Instead:

PHP
// Use these utility functions designed for Eventbrite events:
$data->utilities->get_event_title()      // Instead of the_title()
$data->utilities->get_event_ID()         // Instead of get_the_ID()
$data->utilities->get_event()->summary   // Instead of the_excerpt()
$data->utilities->the_content()          // Instead of the_content()

Available Utility Functions

All utility functions that use $this->get_event() or $this->event internally are safe for template use in version 6.3+. Functions marked with @api in the source code are officially supported for templates.

Event Access

  • $data->utilities->set_event($event) – Set current
    event (REQUIRED in loops)
  • $data->utilities->get_event() – Get current event
    object
  • $data->utilities->get_element($key, $source)
    Safe element access with null checking

Event Core Data

  • $data->utilities->get_event_ID() – Event ID
    (@api)
  • $data->utilities->get_event_title() – Event title
    (@api)
  • $data->utilities->get_event_attr($attr) – Generic
    attribute getter

Event Images

  • $data->utilities->get_event_logo_url() – Logo URL
    (resized) (@api)
  • $data->utilities->get_event_logo_original_url()
    Original logo URL (@api)

Event Dates & Times

  • $data->utilities->get_event_start() – Start date
    object (@api)
  • $data->utilities->get_event_end() – End date
    object (@api)
  • $data->utilities->get_event_time($args, $exclude_date)
    – Formatted time string
  • $data->utilities->get_event_eb_url($ext)
    Eventbrite URL (@api)
  • $data->utilities->get_booknow_link($args)
    Booking link (@api)
  • $data->utilities->get_original_booknow_link($args)
    – Original EB link (@api)
  • $data->utilities->get_cta($args) – Call-to-action
    object (@api)

Event Display

  • $data->utilities->get_event_classes($atts) – CSS
    classes for event
  • $data->utilities->the_content() – Processed event
    content (replaces the_content())

Social Sharing

  • $data->utilities->get_fb_share_href($args)
    Facebook share URL
  • $data->utilities->get_twitter_share_href($args)
    Twitter share URL
  • $data->utilities->get_gcal_href($args) – Google
    Calendar URL
  • $data->utilities->get_outlook_cal_href($args)
    Outlook Calendar URL
  • $data->utilities->get_yahoo_href($args) – Yahoo
    Calendar URL

Premium Functions (suffix: __premium_only)

  • $data->utilities->get_location_display__premium_only($args)
    – Formatted location (@api)
  • $data->utilities->get_venue_name_display__premium_only($args)
    – Venue name
  • $data->utilities->get_price_display__premium_only()
    – Price display (@api)
  • $data->utilities->get_ticket_availablity__premium_only($args)
    – Ticket availability (@api)
  • $data->utilities->get_age_restriction__premium_only($args)
    – Age restrictions (@api)
  • $data->utilities->get_door_time__premium_only($args)
    – Door time (@api)
  • $data->utilities->get_presented_by__premium_only($args)
    – Presented by info (@api)
  • $data->utilities->get_event_classes__premium_only($atts)
    – Premium CSS classes (@api)
  • $data->utilities->get_popup_class__premium_only($args)
    – Modal popup classes (@api)
  • $data->utilities->get_music_headliners__premium_only()
    – Music headliners (@api)
  • $data->utilities->get_music_supporters__premium_only()
    – Music supporters (@api)
  • $data->utilities->get_calendar_fields__premium_only($args)
    – Calendar fields (@api)

Troubleshooting

Issue: Templates Not Loading

  1. Check file names match the layout name
  2. Verify directory structure:
    widget-for-eventbrite-api/
  3. Ensure proper file permissions

Issue: Event Data Not Displaying

  1. Always call $data->utilities->set_event($event)
    in loops
  2. Check if using correct property names (e.g., post_title
    not title)
  3. Verify data exists before accessing nested properties

Issue: WordPress Functions Not Working

  1. Pass the event object:
    get_the_excerpt($data->utilities->get_event())
  2. Don’t use the_post() or
    setup_postdata()
  3. Use utility functions when available

Best Practices

  1. Use Utility Functions: Prefer utility functions
    over direct property access
  2. Check Data Existence: Use
    get_element() for safe access
  3. Escape Output: Always escape data for security
  4. Follow Naming: Match file names to layout
    names
  5. Test Thoroughly: Test with different event types
    and configurations

Summary

The WordPress 6.8 compatibility update in version 6.3+ introduces a critical breaking change: the removal of $data->events->post (singular). All custom templates that directly access event properties via $data->events->post MUST be updated to use:

  1. Utility functions for common properties
    (preferred)
  2. $data->utilities->get_event()->
    for complex/nested properties

This change ensures better compatibility with WordPress 6.8 while providing a cleaner, more maintainable API for accessing event data. Always remember to call $data->utilities->set_event($event) within loops before accessing event data.

Was this helpful?