From d7f56b1fe90073df02519cd206b0af129ea0e8c6 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Thu, 30 Jul 2026 12:45:34 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feature:=20Update=20version=20to=20?= =?UTF-8?q?1.2.6,=20add=20registration=20link=20field,=20and=20enhance=20e?= =?UTF-8?q?vent=20templates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + aa-events.php | 4 ++-- includes/acf-fields.php | 15 ++++++++++++++ includes/template-loader.php | 40 ++++++++++++++++++++++++++++++++++++ templates/aa-events.css | 24 ++++++++++++++++++++++ templates/calendar.php | 35 ------------------------------- templates/single-event.php | 7 +++++++ 7 files changed, 89 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index 36a70d8..3b4baf4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ notes/ +docs/ phpcs-results.txt tests/ diff --git a/aa-events.php b/aa-events.php index ba3e3c7..dfa5f14 100644 --- a/aa-events.php +++ b/aa-events.php @@ -3,7 +3,7 @@ * Plugin Name: AA Events * Plugin URI: https://github.com/automattic/aa-events * Description: An Events management plugin for WordPress, with accessible calendar (WCAG 2.2AA) and card grid views. - * Version: 1.2.5 + * Version: 1.2.6 * Author: Keith Solomon * Author URI: https://vincentdesign.ca * License: GPL-2.0+ @@ -49,7 +49,7 @@ register_deactivation_hook( __FILE__, 'deactivate_aa_events' ); * Define Constants */ define( 'AA_EVENTS_PLUGIN_FILE', __FILE__ ); -define( 'AA_EVENTS_VERSION', '1.2.1' ); +define( 'AA_EVENTS_VERSION', '1.2.6' ); define( 'AA_EVENTS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'AA_EVENTS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); diff --git a/includes/acf-fields.php b/includes/acf-fields.php index 13222b1..e59936e 100644 --- a/includes/acf-fields.php +++ b/includes/acf-fields.php @@ -309,6 +309,21 @@ function events_register_acf_fields() { 'default_value' => '', 'placeholder' => '', ), + array( + 'key' => 'field_aa_events_registration_link', + 'label' => 'Registration Link', + 'name' => 'registration_link', + 'type' => 'link', + 'instructions' => '', + 'required' => 0, + 'conditional_logic' => 0, + 'wrapper' => array( + 'width' => '', + 'class' => '', + 'id' => '', + ), + 'return_format' => 'array', + ), ), 'location' => array( array( diff --git a/includes/template-loader.php b/includes/template-loader.php index 3337b58..5b2c768 100644 --- a/includes/template-loader.php +++ b/includes/template-loader.php @@ -26,6 +26,46 @@ function aa_events_contact_email_markup( $value ) { return '' . wp_kses_post( $protected ) . ''; } +/** + * Build safe registration-link markup for event templates. + * + * @param mixed $value Raw registration link value. + * @return string Escaped registration link, or an empty string for invalid input. + */ +function aa_events_registration_link_markup( $value ) { + if ( is_array( $value ) ) { + if ( ! isset( $value['url'] ) || ! is_string( $value['url'] ) ) { + return ''; + } + + $url = trim( $value['url'] ); + $target = isset( $value['target'] ) && is_string( $value['target'] ) ? $value['target'] : ''; + } elseif ( is_string( $value ) ) { + $url = trim( $value ); + $target = ''; + } else { + return ''; + } + + if ( '' === $url || false === filter_var( $url, FILTER_VALIDATE_URL ) ) { + return ''; + } + + $url_parts = wp_parse_url( $url ); + if ( + ! is_array( $url_parts ) || + empty( $url_parts['host'] ) || + empty( $url_parts['scheme'] ) || + ! in_array( strtolower( $url_parts['scheme'] ), array( 'http', 'https' ), true ) + ) { + return ''; + } + + $target_attributes = '_blank' === $target ? ' target="_blank" rel="noopener noreferrer"' : ''; + + return '' . esc_html( __( 'Register', 'aa-events' ) ) . ''; +} + /** * Load a template. * diff --git a/templates/aa-events.css b/templates/aa-events.css index a101ea5..5a605ac 100644 --- a/templates/aa-events.css +++ b/templates/aa-events.css @@ -285,6 +285,30 @@ div { margin-bottom: 0.625rem; } } +.aa-event-registration-link { + background: #005f73; + border: 2px solid #005f73; + border-radius: 0.25rem; + color: #fff; + display: inline-block; + font-weight: 700; + margin-top: 1.25rem; + padding: 0.625rem 1.25rem; + text-decoration: none; +} + +.aa-event-registration-link:hover { + background: #003f4d; + border-color: #003f4d; + color: #fff; + text-decoration: underline; +} + +.aa-event-registration-link:focus-visible { + outline: 3px solid #111; + outline-offset: 3px; +} + /* Events archive layout */ .aa-events-wrap .aa-events-grid { display: grid; diff --git a/templates/calendar.php b/templates/calendar.php index 5ef26ff..46d271d 100644 --- a/templates/calendar.php +++ b/templates/calendar.php @@ -112,41 +112,6 @@ $events = new WP_Query( 'no_found_rows' => true, 'update_post_meta_cache' => true, 'update_post_term_cache' => false, - 'meta_query' => array( - 'relation' => 'OR', - array( - 'relation' => 'AND', - array( - 'key' => '_aa_events_occurrence_index_version', - 'value' => AA_EVENTS_VERSION, - 'compare' => '=', - ), - array( - 'key' => '_aa_events_sort_start', - 'value' => $month['month_end']->format( 'Y-m-d 23:59:59' ), - 'compare' => '<=', - 'type' => 'DATETIME', - ), - array( - 'key' => '_aa_events_sort_end', - 'value' => $month['month_start']->format( 'Y-m-d 00:00:00' ), - 'compare' => '>=', - 'type' => 'DATETIME', - ), - ), - array( - 'relation' => 'OR', - array( - 'key' => '_aa_events_occurrence_index_version', - 'compare' => 'NOT EXISTS', - ), - array( - 'key' => '_aa_events_occurrence_index_version', - 'value' => AA_EVENTS_VERSION, - 'compare' => '!=', - ), - ), - ), ) ); foreach ( $events->posts as $event_id ) { diff --git a/templates/single-event.php b/templates/single-event.php index 1724b11..715d653 100644 --- a/templates/single-event.php +++ b/templates/single-event.php @@ -93,6 +93,13 @@ get_header(); ?> + + + +
+ +
+