diff --git a/eme-calendar.php b/eme-calendar.php index f27d70b7..2b3e2b38 100644 --- a/eme-calendar.php +++ b/eme-calendar.php @@ -7,6 +7,9 @@ function eme_get_calendar_shortcode( $atts ) { eme_enqueue_frontend(); + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'category' => 0, diff --git a/eme-categories.php b/eme-categories.php index 5c6d2ae5..024e1fcf 100644 --- a/eme-categories.php +++ b/eme-categories.php @@ -467,6 +467,9 @@ function eme_get_category_id_by_name_slug ($cat_name ) { function eme_get_categories_shortcode( $atts ) { eme_enqueue_frontend(); + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'event_id' => 0, diff --git a/eme-events.php b/eme-events.php index fd8bfccd..152e6609 100644 --- a/eme-events.php +++ b/eme-events.php @@ -4539,6 +4539,9 @@ function eme_get_events_list( $limit = -1, $scope = 'future', $order = 'ASC', $f function eme_get_events_list_shortcode( $atts ) { eme_enqueue_frontend(); + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'limit' => -1, @@ -4741,6 +4744,9 @@ function eme_display_single_event( $event_id, $template_id = 0, $ignore_url = 0 function eme_display_single_event_shortcode( $atts ) { eme_enqueue_frontend(); + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'id' => '', @@ -4754,6 +4760,9 @@ function eme_display_single_event_shortcode( $atts ) { function eme_get_events_page_shortcode( $atts ) { eme_enqueue_frontend(); + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'justurl' => 0, @@ -8950,6 +8959,9 @@ function eme_rss_link( $justurl = 0, $echo = 0, $text = 'RSS', $scope = 'future' } function eme_rss_link_shortcode( $atts ) { + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'justurl' => 0, @@ -10035,6 +10047,9 @@ function eme_admin_enqueue_js() { # return number of days until next event or until the specified event function eme_countdown_shortcode( $atts ) { + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'id' => '', diff --git a/eme-filters.php b/eme-filters.php index 729a3ccb..f271036c 100644 --- a/eme-filters.php +++ b/eme-filters.php @@ -6,6 +6,9 @@ function eme_filter_form_shortcode( $atts ) { eme_enqueue_frontend(); + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'multiple' => 0, diff --git a/eme-fs.php b/eme-fs.php index 13ca05a1..b09fe7f2 100644 --- a/eme-fs.php +++ b/eme-fs.php @@ -172,6 +172,9 @@ function eme_generate_fs_event_pdf( $person, $event, $template_id ) { function eme_add_event_form_shortcode( $atts ) { eme_enqueue_frontend(); + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $eme_fs_options = get_option('eme_fs'); $is_user_logged_in=is_user_logged_in(); diff --git a/eme-functions.php b/eme-functions.php index adfe847f..a8fd48f5 100644 --- a/eme-functions.php +++ b/eme-functions.php @@ -488,6 +488,9 @@ function eme_captcha_remove( $captcha_file ) { } function eme_if_shortcode($atts, $content) { + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'tag' => '', @@ -623,6 +626,9 @@ function eme_if_shortcode($atts, $content) { } function eme_for_shortcode( $atts, $content ) { + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'min' => 1, diff --git a/eme-gdpr.php b/eme-gdpr.php index b0d91652..45402996 100644 --- a/eme-gdpr.php +++ b/eme-gdpr.php @@ -104,6 +104,9 @@ function eme_rpi_shortcode( $atts ) { $email = ''; } + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'show_info_if_logged_in' => 0 ], $atts ); $show_info_if_logged_in = filter_var( $atts['show_info_if_logged_in'], FILTER_VALIDATE_BOOLEAN ); @@ -293,6 +296,9 @@ function eme_cpi_shortcode( $atts ) { $email = ''; } + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'show_form_if_logged_in' => 0 ], $atts ); $show_form_if_logged_in = filter_var( $atts['show_form_if_logged_in'], FILTER_VALIDATE_BOOLEAN ); diff --git a/eme-holidays.php b/eme-holidays.php index 44d22b69..b60a9154 100644 --- a/eme-holidays.php +++ b/eme-holidays.php @@ -279,6 +279,9 @@ function eme_get_holidays_array_by_id() { # return number of days until next event or until the specified event function eme_holidays_shortcode( $atts ) { eme_enqueue_frontend(); + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'id' => 0, diff --git a/eme-ical.php b/eme-ical.php index c822457f..02c7ab98 100644 --- a/eme-ical.php +++ b/eme-ical.php @@ -161,6 +161,9 @@ function eme_ical_link( $justurl = 0, $echo = 0, $text = 'ICAL', $category = '', } function eme_ical_link_shortcode( $atts ) { + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + $atts = shortcode_atts( [ 'justurl' => 0, diff --git a/eme-locations.php b/eme-locations.php index 17d6e2ab..1cf71c5a 100644 --- a/eme-locations.php +++ b/eme-locations.php @@ -1515,8 +1515,14 @@ function eme_global_map_shortcode( $atts ) { global $post; eme_enqueue_frontend(); - if ( get_option( 'eme_map_is_active' ) ) { - $defaults = [ + if ( !get_option( 'eme_map_is_active' ) ) { + return ''; + } + // normalize attribute keys, lowercase + $atts = array_change_key_case( (array) $atts, CASE_LOWER ); + + $atts = shortcode_atts( + [ 'show_locations' => true, 'letter_icons' => true, 'show_events' => false, @@ -1531,128 +1537,130 @@ function eme_global_map_shortcode( $atts ) { 'contact_person' => '', 'width' => 450, 'height' => 300, - 'list_location' => 'after', - ]; - $atts = shortcode_atts( $defaults, $atts ); - - $eventful = filter_var( $atts['eventful'], FILTER_VALIDATE_BOOLEAN ); - $show_events = filter_var( $atts['show_events'], FILTER_VALIDATE_BOOLEAN ); - $show_locations = filter_var( $atts['show_locations'], FILTER_VALIDATE_BOOLEAN ); - $marker_clustering = filter_var( $atts['marker_clustering'], FILTER_VALIDATE_BOOLEAN ); - $ignore_filter = filter_var( $atts['ignore_filter'], FILTER_VALIDATE_BOOLEAN ); - $letter_icons = filter_var( $atts['letter_icons'], FILTER_VALIDATE_BOOLEAN ); - $scope = eme_sanitize_request( $atts['scope'] ); - $width = eme_sanitize_request( $atts['width'] ); - $height = eme_sanitize_request( $atts['height'] ); - - wp_enqueue_style( 'eme-leaflet-css' ); - if ( $marker_clustering ) { - wp_enqueue_script( 'eme-leaflet-markercluster' ); - wp_enqueue_style( 'eme-markercluster-css1' ); - wp_enqueue_style( 'eme-markercluster-css2' ); - } - if ( get_option( 'eme_map_gesture_handling' ) ) { - wp_enqueue_script( 'eme-leaflet-gestures' ); - wp_enqueue_style( 'eme-gestures-css' ); - } - wp_enqueue_script( 'eme-show-maps' ); - - $result = ''; - $prev_text = ''; - $next_text = ''; - $scope_offset = 0; - - if ( $eventful && $atts['paging'] == 1 ) { - $eme_date_obj = new ExpressiveDate( 'now', EME_TIMEZONE ); + 'list_location' => 'after' + ], + $atts + ); - if ( isset( $_GET['eme_offset'] ) ) { - $scope_offset = intval( $_GET['eme_offset'] ); - } - $prev_offset = $scope_offset - 1; - $next_offset = $scope_offset + 1; - - if ( $scope == 'this_week' ) { - $start_of_week = get_option( 'start_of_week' ); - $eme_date_obj->setWeekStartDay( $start_of_week ); - $eme_date_obj->modifyWeeks( $scope_offset ); - $limit_start = $eme_date_obj->startOfWeek()->format( 'Y-m-d' ); - $limit_end = $eme_date_obj->endOfWeek()->format( 'Y-m-d' ); - $scope = "$limit_start--$limit_end"; - $scope_text = eme_localized_date( $limit_start, EME_TIMEZONE ) . ' -- ' . eme_localized_date( $limit_end, EME_TIMEZONE ); - $prev_text = __( 'Previous week', 'events-made-easy' ); - $next_text = __( 'Next week', 'events-made-easy' ); - - } elseif ( $scope == 'this_year' ) { - $eme_date_obj->modifyYears( $scope_offset ); - $year = $eme_date_obj->getYear(); - $limit_start = "$year-01-01"; - $limit_end = "$year-12-31"; - $scope = "$limit_start--$limit_end"; - $scope_text = eme_localized_date( $limit_start, EME_TIMEZONE, get_option( 'eme_show_period_yearly_dateformat' ) ); - $prev_text = __( 'Previous year', 'events-made-easy' ); - $next_text = __( 'Next year', 'events-made-easy' ); - - } elseif ( $scope == 'today' ) { - $scope = $eme_date_obj->modifyDays( $scope_offset )->format( 'Y-m-d' ); - $limit_start = $scope; - $limit_end = $scope; - $scope_text = eme_localized_date( $limit_start, EME_TIMEZONE ); - $prev_text = __( 'Previous day', 'events-made-easy' ); - $next_text = __( 'Next day', 'events-made-easy' ); - - } elseif ( $scope == 'tomorrow' ) { - ++$scope_offset; - $scope = $eme_date_obj->modifyDays( $scope_offset )->format( 'Y-m-d' ); - $limit_start = $scope; - $limit_end = $scope; - $scope_text = eme_localized_date( $limit_start, EME_TIMEZONE ); - $prev_text = __( 'Previous day', 'events-made-easy' ); - $next_text = __( 'Next day', 'events-made-easy' ); + $eventful = filter_var( $atts['eventful'], FILTER_VALIDATE_BOOLEAN ); + $show_events = filter_var( $atts['show_events'], FILTER_VALIDATE_BOOLEAN ); + $show_locations = filter_var( $atts['show_locations'], FILTER_VALIDATE_BOOLEAN ); + $marker_clustering = filter_var( $atts['marker_clustering'], FILTER_VALIDATE_BOOLEAN ); + $ignore_filter = filter_var( $atts['ignore_filter'], FILTER_VALIDATE_BOOLEAN ); + $letter_icons = filter_var( $atts['letter_icons'], FILTER_VALIDATE_BOOLEAN ); + $scope = eme_sanitize_request( $atts['scope'] ); + $width = eme_sanitize_request( $atts['width'] ); + $height = eme_sanitize_request( $atts['height'] ); + + wp_enqueue_style( 'eme-leaflet-css' ); + if ( $marker_clustering ) { + wp_enqueue_script( 'eme-leaflet-markercluster' ); + wp_enqueue_style( 'eme-markercluster-css1' ); + wp_enqueue_style( 'eme-markercluster-css2' ); + } + if ( get_option( 'eme_map_gesture_handling' ) ) { + wp_enqueue_script( 'eme-leaflet-gestures' ); + wp_enqueue_style( 'eme-gestures-css' ); + } + wp_enqueue_script( 'eme-show-maps' ); + + $result = ''; + $prev_text = ''; + $next_text = ''; + $scope_offset = 0; + + if ( $eventful && $atts['paging'] == 1 ) { + $eme_date_obj = new ExpressiveDate( 'now', EME_TIMEZONE ); + + if ( isset( $_GET['eme_offset'] ) ) { + $scope_offset = intval( $_GET['eme_offset'] ); + } + $prev_offset = $scope_offset - 1; + $next_offset = $scope_offset + 1; + + if ( $scope == 'this_week' ) { + $start_of_week = get_option( 'start_of_week' ); + $eme_date_obj->setWeekStartDay( $start_of_week ); + $eme_date_obj->modifyWeeks( $scope_offset ); + $limit_start = $eme_date_obj->startOfWeek()->format( 'Y-m-d' ); + $limit_end = $eme_date_obj->endOfWeek()->format( 'Y-m-d' ); + $scope = "$limit_start--$limit_end"; + $scope_text = eme_localized_date( $limit_start, EME_TIMEZONE ) . ' -- ' . eme_localized_date( $limit_end, EME_TIMEZONE ); + $prev_text = __( 'Previous week', 'events-made-easy' ); + $next_text = __( 'Next week', 'events-made-easy' ); + + } elseif ( $scope == 'this_year' ) { + $eme_date_obj->modifyYears( $scope_offset ); + $year = $eme_date_obj->getYear(); + $limit_start = "$year-01-01"; + $limit_end = "$year-12-31"; + $scope = "$limit_start--$limit_end"; + $scope_text = eme_localized_date( $limit_start, EME_TIMEZONE, get_option( 'eme_show_period_yearly_dateformat' ) ); + $prev_text = __( 'Previous year', 'events-made-easy' ); + $next_text = __( 'Next year', 'events-made-easy' ); + + } elseif ( $scope == 'today' ) { + $scope = $eme_date_obj->modifyDays( $scope_offset )->format( 'Y-m-d' ); + $limit_start = $scope; + $limit_end = $scope; + $scope_text = eme_localized_date( $limit_start, EME_TIMEZONE ); + $prev_text = __( 'Previous day', 'events-made-easy' ); + $next_text = __( 'Next day', 'events-made-easy' ); + + } elseif ( $scope == 'tomorrow' ) { + ++$scope_offset; + $scope = $eme_date_obj->modifyDays( $scope_offset )->format( 'Y-m-d' ); + $limit_start = $scope; + $limit_end = $scope; + $scope_text = eme_localized_date( $limit_start, EME_TIMEZONE ); + $prev_text = __( 'Previous day', 'events-made-easy' ); + $next_text = __( 'Next day', 'events-made-easy' ); - } else { - $eme_date_obj->modifyMonths( $scope_offset ); - $limit_start = $eme_date_obj->startOfMonth()->format( 'Y-m-d' ); - $limit_end = $eme_date_obj->endOfMonth()->format( 'Y-m-d' ); - $scope = "$limit_start--$limit_end"; - $scope_text = eme_localized_date( $limit_start, EME_TIMEZONE, get_option( 'eme_show_period_monthly_dateformat' ) ); - $prev_text = __( 'Previous month', 'events-made-easy' ); - $next_text = __( 'Next month', 'events-made-easy' ); + } else { + $eme_date_obj->modifyMonths( $scope_offset ); + $limit_start = $eme_date_obj->startOfMonth()->format( 'Y-m-d' ); + $limit_end = $eme_date_obj->endOfMonth()->format( 'Y-m-d' ); + $scope = "$limit_start--$limit_end"; + $scope_text = eme_localized_date( $limit_start, EME_TIMEZONE, get_option( 'eme_show_period_monthly_dateformat' ) ); + $prev_text = __( 'Previous month', 'events-made-easy' ); + $next_text = __( 'Next month', 'events-made-easy' ); - } + } - $older_events = eme_get_events( limit: 1, scope: '--' . $limit_start, category: $atts['category'], show_ongoing: 1, notcategory: $atts['notcategory'] ); - $newer_events = eme_get_events( limit: 1, scope: '++' . $limit_end, category: $atts['category'], show_ongoing: 1, notcategory: $atts['notcategory'] ); - if ( count( $older_events ) == 0 ) { - $prev_text = ''; - } - if ( count( $newer_events ) == 0 ) { - $next_text = ''; - } + $older_events = eme_get_events( limit: 1, scope: '--' . $limit_start, category: $atts['category'], show_ongoing: 1, notcategory: $atts['notcategory'] ); + $newer_events = eme_get_events( limit: 1, scope: '++' . $limit_end, category: $atts['category'], show_ongoing: 1, notcategory: $atts['notcategory'] ); + if ( count( $older_events ) == 0 ) { + $prev_text = ''; } + if ( count( $newer_events ) == 0 ) { + $next_text = ''; + } + } - $limit = 0; - $ignore_filter = false; - $random_order = false; - $locations = eme_get_locations( eventful: $eventful, scope: $scope, category: $atts['category'], notcategory: $atts['notcategory'], limit: $limit, ignore_filter: $ignore_filter, random_order: $random_order, author: $atts['author'], contact_person: $atts['contact_person'] ); - $id_base = preg_replace( '/\D/', '_', microtime( 1 ) ); - $id_base = rand() . '_' . $id_base; - if ( ! empty( $width ) && ! empty( $height ) ) { - if ( ! preg_match( '/\%$|px$|fr$|em$/', $width ) ) { - $width = $width . 'px'; - } - if ( ! preg_match( '/\%$|px$|fr$|em$/', $height ) ) { - $height = $height . 'px'; - } - $style = "style='width: $width; height: $height'"; - } else { - $style = ''; + $limit = 0; + $ignore_filter = false; + $random_order = false; + $locations = eme_get_locations( eventful: $eventful, scope: $scope, category: $atts['category'], notcategory: $atts['notcategory'], limit: $limit, ignore_filter: $ignore_filter, random_order: $random_order, author: $atts['author'], contact_person: $atts['contact_person'] ); + $id_base = preg_replace( '/\D/', '_', microtime( 1 ) ); + $id_base = rand() . '_' . $id_base; + $style = ''; + if ( ! empty( $width ) && ! empty( $height ) ) { + if ( ! preg_match( '/\%$|px$|fr$|em$/', $width ) ) { + $width = $width . 'px'; + } + if ( ! preg_match( '/\%$|px$|fr$|em$/', $height ) ) { + $height = $height . 'px'; } - if ( ! empty( $locations ) ) { - $result = "