AdminFormListView.php
70 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\DonationForms\AsyncData\AdminFormListView; |
| 4 | |
| 5 | use Give\DonationForms\AsyncData\AsyncDataHelpers; |
| 6 | |
| 7 | /** |
| 8 | * @since 3.16.0 |
| 9 | */ |
| 10 | class AdminFormListView |
| 11 | { |
| 12 | /** |
| 13 | * @since 3.16.0 |
| 14 | */ |
| 15 | public function maybeChangeAchievedIconOpacity($achievedIconOpacity) |
| 16 | { |
| 17 | if (AdminFormListViewOptions::isGoalColumnAsync()) { |
| 18 | $achievedIconOpacity = 0; |
| 19 | } |
| 20 | |
| 21 | return $achievedIconOpacity; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * @since 3.16.0 |
| 26 | */ |
| 27 | public function maybeUsePlaceholderOnGoalAmountRaised(bool $usePlaceholder = false): bool |
| 28 | { |
| 29 | if (AdminFormListViewOptions::isGoalColumnAsync()) { |
| 30 | $usePlaceholder = true; |
| 31 | } |
| 32 | |
| 33 | return $usePlaceholder; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @since 3.16.0 |
| 38 | */ |
| 39 | public function maybeSetDonationsColumnAsync($donationsCountCachedValue, $formId) |
| 40 | { |
| 41 | if (AdminFormListViewOptions::isDonationColumnAsync()) { |
| 42 | return AsyncDataHelpers::getSkeletonPlaceholder('1rem'); |
| 43 | } |
| 44 | |
| 45 | if (AdminFormListViewOptions::useCachedMetaKeys()) { |
| 46 | return $donationsCountCachedValue; |
| 47 | } |
| 48 | |
| 49 | return AsyncDataHelpers::getFormDonationsCountValue($formId); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * @since 3.16.0 |
| 54 | */ |
| 55 | public function maybeSetRevenueColumnAsync($revenueCachedValue, $formId) |
| 56 | { |
| 57 | if (AdminFormListViewOptions::isRevenueColumnAsync()) { |
| 58 | return AsyncDataHelpers::getSkeletonPlaceholder('1rem'); |
| 59 | } |
| 60 | |
| 61 | if (AdminFormListViewOptions::useCachedMetaKeys()) { |
| 62 | return $revenueCachedValue; |
| 63 | } |
| 64 | |
| 65 | $revenue = AsyncDataHelpers::getFormRevenueValue($formId); |
| 66 | |
| 67 | return give_currency_filter(give_format_amount($revenue)); |
| 68 | } |
| 69 | } |
| 70 |