PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.15.5
Independent Analytics – WordPress Analytics Plugin v2.15.5
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / nesbot / carbon / sponsors.php
independent-analytics / vendor / nesbot / carbon Last commit date
bin 2 years ago lazy 2 years ago src 1 month ago extension.neon 3 years ago sponsors.php 2 years ago
sponsors.php
80 lines
1 <?php
2
3 namespace IAWPSCOPED;
4
5 /**
6 * This file is part of the Carbon package.
7 *
8 * (c) Brian Nesbitt <brian@nesbot.com>
9 *
10 * For the full copyright and license information, please view the LICENSE
11 * file that was distributed with this source code.
12 */
13 use IAWPSCOPED\Carbon\CarbonImmutable;
14 require_once __DIR__ . '/vendor/autoload.php';
15 /** @internal */
16 function getMaxHistoryMonthsByAmount($amount) : int
17 {
18 if ($amount >= 50) {
19 return 6;
20 }
21 if ($amount >= 20) {
22 return 4;
23 }
24 return 2;
25 }
26 /** @internal */
27 function getHtmlAttribute($rawValue) : string
28 {
29 return \str_replace(['', "\r"], '', \trim(\htmlspecialchars((string) $rawValue), "  \n\r\t\v\x00"));
30 }
31 /** @internal */
32 function getOpenCollectiveSponsors() : string
33 {
34 $customSponsorImages = [];
35 $members = \json_decode(\file_get_contents('https://opencollective.com/carbon/members/all.json'), \true);
36 $list = \array_filter($members, static function ($member) : bool {
37 return ($member['lastTransactionAmount'] > 3 || $member['isActive']) && $member['role'] === 'BACKER' && $member['type'] !== 'USER' && ($member['totalAmountDonated'] > 100 || $member['lastTransactionAt'] > CarbonImmutable::now()->subMonthsNoOverflow(getMaxHistoryMonthsByAmount($member['lastTransactionAmount']))->format('Y-m-d h:i') || $member['isActive'] && $member['lastTransactionAmount'] >= 30);
38 });
39 $list = \array_map(static function (array $member) : array {
40 $createdAt = CarbonImmutable::parse($member['createdAt']);
41 $lastTransactionAt = CarbonImmutable::parse($member['lastTransactionAt']);
42 if ($createdAt->format('d H:i:s.u') > $lastTransactionAt->format('d H:i:s.u')) {
43 $createdAt = $createdAt->setDay($lastTransactionAt->day)->modify($lastTransactionAt->format('H:i:s.u'));
44 }
45 $monthlyContribution = (float) ($member['totalAmountDonated'] / \ceil($createdAt->floatDiffInMonths()));
46 if ($lastTransactionAt->isAfter('last month') && $member['lastTransactionAmount'] > $monthlyContribution) {
47 $monthlyContribution = (float) $member['lastTransactionAmount'];
48 }
49 $yearlyContribution = (float) ($member['totalAmountDonated'] / \max(1, $createdAt->floatDiffInYears()));
50 $status = null;
51 if ($monthlyContribution > 29) {
52 $status = 'sponsor';
53 } elseif ($monthlyContribution > 4.5 || $yearlyContribution > 29) {
54 $status = 'backer';
55 } elseif ($member['totalAmountDonated'] > 0) {
56 $status = 'helper';
57 }
58 return \array_merge($member, ['star' => $monthlyContribution > 98 || $yearlyContribution > 500, 'status' => $status, 'monthlyContribution' => $monthlyContribution, 'yearlyContribution' => $yearlyContribution]);
59 }, $list);
60 \usort($list, static function (array $a, array $b) : int {
61 return $b['monthlyContribution'] <=> $a['monthlyContribution'] ?: $b['totalAmountDonated'] <=> $a['totalAmountDonated'];
62 });
63 return \implode('', \array_map(static function (array $member) use($customSponsorImages) : string {
64 $href = \htmlspecialchars($member['website'] ?? $member['profile']);
65 $src = $customSponsorImages[$member['MemberId'] ?? ''] ?? $member['image'] ?? \strtr($member['profile'], ['https://opencollective.com/' => 'https://images.opencollective.com/']) . '/avatar/256.png';
66 [$x, $y] = @\getimagesize($src) ?: [0, 0];
67 $validImage = $x && $y;
68 $src = $validImage ? \htmlspecialchars($src) : 'https://opencollective.com/static/images/default-guest-logo.svg';
69 $height = $member['status'] === 'sponsor' ? 64 : 42;
70 $width = \min($height * 2, $validImage ? \round($x * $height / $y) : $height);
71 $href .= (\strpos($href, '?') === \false ? '?' : '&amp;') . 'utm_source=opencollective&amp;utm_medium=github&amp;utm_campaign=Carbon';
72 $title = getHtmlAttribute($member['description'] ?? null ?: $member['name']);
73 $alt = getHtmlAttribute($member['name']);
74 return "\n" . '<a title="' . $title . '" href="' . $href . '" target="_blank">' . '<img alt="' . $alt . '" src="' . $src . '" width="' . $width . '" height="' . $height . '">' . '</a>';
75 }, $list)) . "\n";
76 }
77 \file_put_contents('readme.md', \preg_replace_callback('/(<!-- <open-collective-sponsors> -->)[\\s\\S]+(<!-- <\\/open-collective-sponsors> -->)/', static function (array $match) : string {
78 return $match[1] . getOpenCollectiveSponsors() . $match[2];
79 }, \file_get_contents('readme.md')));
80