Skip to content

Commit

Permalink
Pass next_page attribute to list block
Browse files Browse the repository at this point in the history
  • Loading branch information
trymebytes committed Nov 28, 2024
1 parent 200fded commit 7c40b21
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 5 additions & 3 deletions includes/routes/event/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ public function handle(): void {
if ( isset( $_GET['format'] ) ) {

Check warning on line 66 in includes/routes/event/list.php

View workflow job for this annotation

GitHub Actions / phpcs

Processing form data without nonce verification.
$value = sanitize_text_field( wp_unslash( $_GET['format'] ) );

Check warning on line 67 in includes/routes/event/list.php

View workflow job for this annotation

GitHub Actions / phpcs

Processing form data without nonce verification.
if ( 'html' == $value && ! empty( $filter_key ) ) {

Check warning on line 68 in includes/routes/event/list.php

View workflow job for this annotation

GitHub Actions / phpcs

Loose comparisons are not allowed. Expected: "==="; Found: "=="
$event_ids = $tmpl_args[ $filter_key ]->event_ids;
$page_left = $tmpl_args[ $filter_key ]->page_count - $tmpl_args[ $filter_key ]->current_page;
$event_ids = $tmpl_args[ $filter_key ]->event_ids;
$current_page = $tmpl_args[ $filter_key ]->current_page;
$page_count = $tmpl_args[ $filter_key ]->page_count;
$next_page = ( ( $current_page + 1 ) <= $page_count ) ? $current_page + 1 : 0;

$list_block_markup = '<!-- wp:wporg-translate-events-2024/event-list ' . wp_json_encode(
array(
'event_ids' => $event_ids,
'page_left' => $page_left,
'next_page' => $next_page,
)
) . ' /-->';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
<?php
namespace Wporg\TranslationEvents\Theme_2024;

$event_ids = $attributes['event_ids'] ?? array();
$event_ids = $attributes['event_ids'] ?? array();
$current_events_query = $attributes['current_events_query'];
$upcoming_events_query = $attributes['upcoming_events_query'];
$past_events_query = $attributes['past_events_query'];

$current_events_data = array(
'event_ids' => $attributes['current_events_query']['event_ids'] ?? array(),
'event_ids' => $current_events_query['event_ids'] ?? array(),
'filter_by' => 'current',
'next_page' => ( $current_events_query['page_count'] >= $current_events_query['current_page'] + 1 ) ? $current_events_query['current_page'] + 1 : 0,
);

$upcoming_events_data = array(
'event_ids' => $attributes['upcoming_events_query']['event_ids'] ?? array(),
'event_ids' => $upcoming_events_query['event_ids'] ?? array(),
'filter_by' => 'upcoming',
'next_page' => ( $upcoming_events_query['page_count'] >= $upcoming_events_query['current_page'] + 1 ) ? $upcoming_events_query['current_page'] + 1 : 0,

);

$past_events_data = array(
'event_ids' => $attributes['past_events_query']['event_ids'] ?? array(),
'filter_by' => 'past',
'next_page' => ( $past_events_query['page_count'] >= $past_events_query['current_page'] + 1 ) ? $past_events_query['current_page'] + 1 : 0,

);

?>
Expand Down

0 comments on commit 7c40b21

Please sign in to comment.