DYS Events for BandsInTown
A WordPress plugin that integrates with the BandsInTown API to display concert events for artists. Supports both shortcode and Gutenberg block functionality with caching, security validation, and full internationalization support.
by Silvère Oriat · github.com/igecode/dys-bandsintown · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/igecode/dys-bandsintown/archive/refs/heads/master.zipA WordPress plugin that integrates with the BandsInTown API to display concert events for artists. Supports both shortcode and Gutenberg block functionality with caching, security validation, and full internationalization support.
Tested up to: 6.48 License: GPL v2 or later Stable tag: 1.0.2
Features
- Dual Integration: Use either shortcode or Gutenberg block
- Flexible Display: List or grid view options
- Advanced Period Modes: Smart mode (automatic), upcoming only, past only, or all events
- Event Filtering: Include/exclude past events with smart logic
- Sorting Options: Sort events by date (newest/oldest first) with period-specific logic
- Customizable Styling: Primary color picker for block customization
- Caching: Built-in transient caching for improved performance (1-hour expiration)
- Security: Comprehensive input validation and sanitization
- Accessibility: ARIA labels, semantic HTML, and keyboard navigation
- Localization: Full internationalization support with POT files
- RTL Support: Right-to-left language support
- Responsive Design: Mobile-friendly layouts
- Error Handling: Graceful error handling with user-friendly messages
- REST API Integration: Server-side rendering with REST API preview
Requirements
- WordPress 5.0 or higher
- PHP 7.4 or higher
- Composer (for PHP dependency management)
- Node.js and npm (for building JavaScript/CSS assets)
- Guzzle HTTP library (installed via Composer)
Installation
Manual Installation
- Download the plugin zip file
- Extract the contents to
wp-content/plugins/dys-events-for-bandsintown/ - Activate the plugin through the WordPress admin dashboard
- Install PHP dependencies:
composer install - Install Node.js dependencies:
npm install - Build production assets:
npm run build
Composer Installation
composer require dys/bandsintown
WordPress.org Installation
- Go to Plugins > Add New in your WordPress admin
- Search for "DYS Events for BandsInTown"
- Click Install Now and activate
Configuration
Getting a BandsInTown API Key
- Visit BandsInTown
- Create an account or log in
- Go to your account settings
- Generate an API key in the developer section
Usage
Shortcode
Add the following shortcode to any post, page, or widget:
[dys_bandsintown artiste="Artist Name" apikey="your_api_key"]
Shortcode Parameters
artiste(required): The artist name as it appears on BandsInTownapikey(required): Your BandsInTown API keynumShows(optional): Number of events to display (1-50, default: 10)displayMode(optional): Display format - 'list' or 'grid' (default: 'list')sortByDate(optional): Sort order - 'desc' or 'asc' (default: 'desc') - only applies when periodMode is 'all'periodMode(optional): Period mode - 'smart', 'upcoming', 'past', or 'all' (default: 'smart')primaryColor(optional): Primary color for styling (hex color, default: '#007cba')
Examples
// Basic usage
[dys_bandsintown artiste="Desybes" apikey="your_api_key"]
// Advanced usage with all options
[dys_bandsintown artiste="Desybes" apikey="your_api_key" numShows="20" displayMode="grid" periodMode="all" sortByDate="asc" primaryColor="#ff0000"]
Gutenberg Block
- In the WordPress editor, click the "+" button to add a new block
- Search for "DYS Events for BandsInTown"
- Configure the settings in the block sidebar:
- Artist Name: Enter the artist name as it appears on BandsInTown
- API Key: Enter your BandsInTown API key
- Number of Shows: Set maximum events to display (1-50)
- Display Mode: Choose between list or grid view
- Period Mode: Choose smart (automatic), upcoming only, past only, or all events
- Sort by Date: Choose newest or oldest first (only shown when Period Mode is "All")
- Primary Color: Choose the primary color for the block elements
API Documentation
Classes
DYS_Bandsintown
Main class for handling BandsInTown integration.
Methods:
__construct($artiste, $apikey, $numShows, $displayMode, $sortByDate, $periodMode): Initialize the classgetEvents($events_periode): Fetch events from API for specified periodgetArtiste(): Fetch artist information from APIrender(): Render the complete events HTML with error handlingrenderEvent($event, $mode): Render individual event HTMLrender_error_state($message): Render error state HTMLlog_error($message): Log error messages for debugging
DYS_Bandsintown_API_Handler
Handles API communication with Guzzle HTTP client, caching, and error handling.
Methods:
__construct($artist, $api_key): Initialize API handler with validationget_artist(): Fetch and cache artist data from BandsInTown APIget_events($period): Fetch and cache events data for specified perioddecode_json($json_string): Safely decode JSON responseslog_error($message): Log error messages for debugging
DYS_Bandsintown_Security_Validator
Provides comprehensive input validation and sanitization for security.
Static Methods:
validate_artist($artist): Validate and sanitize artist namevalidate_api_key($api_key): Validate and sanitize API keyvalidate_num_shows($num_shows): Validate number of shows (1-50)validate_display_mode($display_mode): Validate display mode ('list' or 'grid')validate_sort_by_date($sort_by_date): Validate sort order ('asc' or 'desc')validate_period_mode($period_mode): Validate period mode ('smart', 'upcoming', 'past', 'all')validate_primary_color($primary_color): Validate hex color formatvalidate_block_attributes($attributes): Validate all block attributessanitize_html_output($html): Sanitize HTML output for security
DYS_Bandsintown_Localization
Handles internationalization and localization with WordPress standards.
Static Methods:
init(): Initialize localization systemload_textdomain(): Load plugin text domainset_locale($locale): Set locale for date/time formattingformat_date($date_string, $format): Format dates with localizationformat_time($date_string, $format): Format times with localizationget_period_label($period): Get localized period labelsget_no_events_message($period): Get localized no-events messagesis_rtl(): Check if current locale is RTLget_rtl_class(): Get RTL-aware CSS class
Hooks and Filters
Actions
dys_bandsintown_load_textdomain: Fired when loading text domainplugins_loaded: Standard WordPress hook for plugin initializationinit: WordPress hook for registering block typesrest_api_init: WordPress hook for registering REST API routesenqueue_block_editor_assets: WordPress hook for block editor assetswp_enqueue_scripts: WordPress hook for frontend styles
Filters
dys_bandsintown_locale: Filter for modifying localelocale: WordPress core filter for locale modification
JavaScript API
The Gutenberg block provides the following JavaScript components:
Edit: Block editor component with live preview and settings panelSave: Block save component (server-side rendering)index.js: Main block registration fileedit.js: Editor component with React hooks and API integrationsave.js: Save component for server-side rendering
Block Attributes
artiste: Artist name (string)apikey: API key (string)numShows: Number of events (number, 1-50)displayMode: Display format ('list' or 'grid')sortByDate: Sort order ('asc' or 'desc')periodMode: Period mode ('smart', 'upcoming', 'past', 'all')primaryColor: Primary color (hex string)
Styling
The plugin includes responsive CSS with support for:
- Light/dark themes
- RTL languages
- Mobile devices
- Accessibility features
CSS Classes
.dysbit_container: Main container with responsive design.dysbit_event: Individual event item.dysbit_infos: Event information wrapper.dysbit_date: Event date and time section.dysbit_title: Event venue and location section.dysbit_link: Event action link.dysbit_events_container: Events list container.dysbit_page_link: Footer link to BandsInTown.dysbit_error: Error message container.dysbit_no_events: No events message.dysbit_grid: Grid layout modifier.dysbit_rtl: RTL layout modifier
CSS Custom Properties
--dys-bit-primary-color: Primary color for theming (default: #007cba)
Development
Setup Development Environment
- Clone the repository:
git clone https://github.com/Igecode/dys-events-for-bandsintown.git - Install PHP dependencies:
composer install - Install Node.js dependencies:
npm install - Build production assets:
npm run build - Start development mode with hot reloading:
npm run start
Available Scripts
npm run build: Build production assets for distributionnpm run start: Start development mode with hot reloading and file watchingnpm run test: Run JavaScript unit tests with Jestnpm run lint:js: Lint JavaScript files with ESLintnpm run lint:css: Lint CSS/SCSS files with Stylelintnpm run format: Format code with Prettier
Testing
Run PHP unit tests with PHPUnit:
composer test
Run JavaScript unit tests with Jest:
npm run test
Run integration tests:
composer integration-test
Code Standards
This plugin follows WordPress coding standards. Run PHP code sniffing:
composer run phpcs
Fix PHP coding standard issues automatically:
composer run phpcbf
Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Changelog
Version 1.0.0
- Complete rewrite with modern architecture
- Advanced period modes (smart, upcoming, past, all)
- Enhanced Gutenberg block with live preview
- REST API integration for block preview
- Comprehensive security validation
- Improved caching system (1-hour transients)
- Full internationalization with POT files
- RTL language support
- Customizable primary colors
- Responsive design improvements
- Extensive error handling
- Unit and integration tests
- WordPress coding standards compliance
Version 0.1.0
- Initial release
- Basic shortcode functionality
- Simple Gutenberg block support
- Basic caching and security features
- Localization support
License
This plugin is licensed under the GPL v2 or later.
Copyright (C) 2024 Silvère Oriat
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Support
For support, please:
- Check this documentation
- Open an issue on GitHub
- Contact the author
Credits
- Author: Silvère Oriat
- Best metal band: Desybes
- API: BandsInTown (https://www.bandsintown.com/)
- Built with: WordPress, React, PHP, Guzzle HTTP
- Testing: PHPUnit, Jest, Testing Library
- Development Tools: WordPress Scripts, ESLint, Stylelint, Prettier
Disclaimer
This plugin is not officially affiliated with BandsInTown. Please refer to BandsInTown's terms of service for API usage guidelines.