Skip to content

Commit a171eb7

Browse files
authored
Docs: Sponsor Agreement: Resolve fatal & warning under PHP 8.1,
NumberFormatter->format() can only accept an `int|float` and not a stringy float, cast it to avoid a fatal. The WordCamp location metadata isn't always available, so we'll also default that to blank.
1 parent 3a08a0d commit a171eb7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

public_html/wp-content/plugins/wordcamp-docs/templates/sponsorship-agreement.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function form( $data ) {
6767
$end_date = ! empty( $wordcamp->meta['End Date (YYYY-mm-dd)'][0] ) ? gmdate( $date_format, $wordcamp->meta['End Date (YYYY-mm-dd)'][0] ) : $start_date;
6868

6969
$number_formatter = new NumberFormatter( get_locale(), NumberFormatter::SPELLOUT );
70-
$sponsorship_amount = $number_formatter->format( $sponsor_amount ) . " {$sponsor_currency}";
70+
$sponsorship_amount = $number_formatter->format( (float) $sponsor_amount ) . " {$sponsor_currency}";
7171

7272
$number_formatter = new NumberFormatter( get_locale(), NumberFormatter::CURRENCY );
7373
$sponsorship_amount_num = $number_formatter->formatCurrency( $sponsor_amount, $sponsor_currency );
@@ -77,7 +77,7 @@ public function form( $data ) {
7777
'sponsor_rep_name' => get_post_meta( $sponsor_id, '_wcpt_sponsor_first_name', true ) . ' ' . get_post_meta( $sponsor_id, '_wcpt_sponsor_last_name', true ),
7878
'sponsor_rep_title' => '',
7979
'agreement_date' => wp_date( $date_format ),
80-
'wordcamp_location' => $wordcamp->meta['Location'][0],
80+
'wordcamp_location' => $wordcamp->meta['Location'][0] ?? '',
8181
'wordcamp_date' => ( $start_date !== $end_date ) ? "{$start_date} - {$end_date}" : $start_date,
8282
'sponsorship_amount' => $sponsorship_amount,
8383
'sponsorship_amount_num' => $sponsorship_amount_num,

0 commit comments

Comments
 (0)