From 00181e88b59632baae9e583bbbf04c18cd45ea83 Mon Sep 17 00:00:00 2001 From: StevenDufresne Date: Thu, 7 Dec 2023 13:05:48 +0900 Subject: [PATCH 1/3] Swap out google maps on homepage for event list. --- .../patterns/front-events.php | 2 +- .../src/event-list/block.json | 4 ++ .../src/event-list/index.php | 48 +++++++++++++++++-- .../templates/page-upcoming.html | 2 +- .../wporg-events-2023/templates/search.html | 2 +- 5 files changed, 51 insertions(+), 7 deletions(-) diff --git a/public_html/wp-content/themes/wporg-events-2023/patterns/front-events.php b/public_html/wp-content/themes/wporg-events-2023/patterns/front-events.php index 436cc8999a..bbc67a2b07 100644 --- a/public_html/wp-content/themes/wporg-events-2023/patterns/front-events.php +++ b/public_html/wp-content/themes/wporg-events-2023/patterns/front-events.php @@ -15,7 +15,7 @@ - +
diff --git a/public_html/wp-content/themes/wporg-events-2023/src/event-list/block.json b/public_html/wp-content/themes/wporg-events-2023/src/event-list/block.json index fc7f79833e..41bf7ad48e 100644 --- a/public_html/wp-content/themes/wporg-events-2023/src/event-list/block.json +++ b/public_html/wp-content/themes/wporg-events-2023/src/event-list/block.json @@ -13,6 +13,10 @@ "type": "string", "default": "all-upcoming" }, + "groupByMonth": { + "type": "boolean", + "default": false + }, "limit": { "type": "number", "default": 100 diff --git a/public_html/wp-content/themes/wporg-events-2023/src/event-list/index.php b/public_html/wp-content/themes/wporg-events-2023/src/event-list/index.php index e0f747db24..b91b6f257d 100644 --- a/public_html/wp-content/themes/wporg-events-2023/src/event-list/index.php +++ b/public_html/wp-content/themes/wporg-events-2023/src/event-list/index.php @@ -45,6 +45,7 @@ function render( $attributes, $content, $block ) { // Get all the filters that are currently applied. $filtered_events = array_slice( filter_events( $events ), 0, (int) $attributes['limit'] ); +<<<<<<< HEAD // Group events by month year. $grouped_events = array(); foreach ( $filtered_events as $event ) { @@ -67,14 +68,30 @@ function render( $attributes, $content, $block ) { esc_html( gmdate('H:i', $event->timestamp) . ' UTC' ), ); $content .= ''; +======= + if ( (bool) $attributes['groupByMonth'] ) { + // Group events by month year. + $grouped_events = array(); + foreach ( $filtered_events as $event ) { + $event_month_year = gmdate( 'F Y', esc_html( $event->timestamp ) ); + $grouped_events[ $event_month_year ][] = $event; +>>>>>>> 8c15c1d3 (Swap out google maps on homepage for event list.) } - $content .= ''; + $content = ''; + foreach ( $grouped_events as $month_year => $events ) { + $content .= get_section_title( $month_year ); + $content .= get_list_markup( $events ); + + echo '
';
+			print_r( $month_year );
+			echo '
'; + } + } else { + $content = get_list_markup( $filtered_events ); } - $wrapper_attributes = get_block_wrapper_attributes( array( - 'class' => 'wp-block-wporg-google-map', - ) ); + $wrapper_attributes = get_block_wrapper_attributes(); return sprintf( '
%2$s
', $wrapper_attributes, @@ -82,6 +99,29 @@ function render( $attributes, $content, $block ) { ); } +/** + * Returns the event-list markup. + * + * @param array $events Array of events. + * + * @return string + */ +function get_list_markup( $events ) { + $block_markup = ''; + + return $block_markup; +} + /** * Get the query var facts and sanitize them. * diff --git a/public_html/wp-content/themes/wporg-events-2023/templates/page-upcoming.html b/public_html/wp-content/themes/wporg-events-2023/templates/page-upcoming.html index 9722de7614..e91a7750f9 100644 --- a/public_html/wp-content/themes/wporg-events-2023/templates/page-upcoming.html +++ b/public_html/wp-content/themes/wporg-events-2023/templates/page-upcoming.html @@ -13,7 +13,7 @@ - +
diff --git a/public_html/wp-content/themes/wporg-events-2023/templates/search.html b/public_html/wp-content/themes/wporg-events-2023/templates/search.html index 22838a1cbc..22f6c5e6d2 100644 --- a/public_html/wp-content/themes/wporg-events-2023/templates/search.html +++ b/public_html/wp-content/themes/wporg-events-2023/templates/search.html @@ -11,7 +11,7 @@ style="padding-right:var(--wp--preset--spacing--edge-space);padding-bottom:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--edge-space)"> - + From 565e094686dbb2b5d29e00a4cfe47c56230e8755 Mon Sep 17 00:00:00 2001 From: StevenDufresne Date: Thu, 7 Dec 2023 13:37:20 +0900 Subject: [PATCH 2/3] Merge back in the time changes. --- .../src/event-list/index.php | 32 ++++--------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/public_html/wp-content/themes/wporg-events-2023/src/event-list/index.php b/public_html/wp-content/themes/wporg-events-2023/src/event-list/index.php index b91b6f257d..64453af27a 100644 --- a/public_html/wp-content/themes/wporg-events-2023/src/event-list/index.php +++ b/public_html/wp-content/themes/wporg-events-2023/src/event-list/index.php @@ -45,37 +45,12 @@ function render( $attributes, $content, $block ) { // Get all the filters that are currently applied. $filtered_events = array_slice( filter_events( $events ), 0, (int) $attributes['limit'] ); -<<<<<<< HEAD - // Group events by month year. - $grouped_events = array(); - foreach ( $filtered_events as $event ) { - $event_month_year = gmdate('F Y', esc_html( $event->timestamp) ); - $grouped_events[ $event_month_year ][] = $event; - } - - foreach ( $grouped_events as $month_year => $events ) { - $content .= get_section_title( $month_year ); - $content .= '