PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 All 257 releases
give / src / DonationForms / resources / shared / AmountMessages.tsx

AmountMessages.tsx in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at src/DonationForms/resources/shared/AmountMessages.tsx

53 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {createInterpolateElement} from '@wordpress/element';
2 import {__} from '@wordpress/i18n';
3 import {subscriptionPeriod, SubscriptionPeriod} from "../registrars/templates/groups/DonationAmount/subscriptionPeriod";
4
5 /**
6 * Returns the donor-facing message for a fixed amount donation.
7 *
8 * @since 3.0.0
9 */
10 export function OneTimeAmountMessage({amount}: {amount: string}) {
11 return createInterpolateElement(__('This donation is <amount/>', 'give'), {
12 amount: <strong>{amount}</strong>,
13 });
14 }
15
16 /**
17 * Returns the donor-facing message for a recurring donation.
18 *
19 * @since 3.0.0
20 */
21 export function RecurringAmountMessage({
22 isFixedAmount,
23 fixedAmount,
24 period,
25 frequency,
26 installments,
27 }: {
28 isFixedAmount: boolean;
29 fixedAmount: string;
30 period: subscriptionPeriod;
31 frequency: number;
32 installments: number;
33 }) {
34 const subscriptionPeriod = new SubscriptionPeriod(period);
35
36 const translatableString = !installments
37 ? __('This donation <amount /> every <period />.', 'give')
38 : __('This donation <amount /> every <period /> for <count /> <donations />.', 'give');
39
40 return createInterpolateElement(translatableString, {
41 amount: isFixedAmount ? (
42 <span>
43 {__('is', 'give')} <strong>{fixedAmount}</strong>
44 </span>
45 ) : (
46 <span>{__('repeats', 'give')}</span>
47 ),
48 period: <strong>{subscriptionPeriod.label().get(frequency)}</strong>,
49 count: <strong>{installments}</strong>,
50 donations: <strong>{__('donations', 'give')}</strong>,
51 });
52 }
53