feature: Update version to 1.2.6, add registration link field, and enhance event templates

This commit is contained in:
Keith Solomon
2026-07-30 12:45:34 -05:00
parent 0fc424b035
commit d7f56b1fe9
7 changed files with 89 additions and 37 deletions
+40
View File
@@ -26,6 +26,46 @@ function aa_events_contact_email_markup( $value ) {
return '<a href="' . esc_attr( 'mailto:' . $protected ) . '">' . wp_kses_post( $protected ) . '</a>';
}
/**
* 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 '<a class="aa-event-registration-link button" href="' . esc_url( $url ) . '"' . $target_attributes . '>' . esc_html( __( 'Register', 'aa-events' ) ) . '</a>';
}
/**
* Load a template.
*