PluginProbe ʕ •ᴥ•ʔ
Presto Player / trunk
Presto Player vtrunk
4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / src / admin / dashboard / components / UpgradeNotice.js
presto-player / src / admin / dashboard / components Last commit date
Emails 1 month ago EngagementChart 1 month ago MediaHub 1 month ago Onboarding 1 month ago Popup 1 month ago Skeletons 1 week ago WhatsNew 1 month ago charts 1 month ago test 1 month ago AdminMenuSync.js 1 month ago ChartEmptyState.js 1 month ago ChooseDate.js 1 month ago ColorPicker.js 1 month ago ExtendPlugins.js 1 month ago Filters.js 1 month ago Link.js 1 month ago Navbar.js 1 week ago NoFound.js 1 month ago PageHeader.js 1 month ago PluginRecommendations.js 1 month ago PostScheduleField.js 1 month ago PrestoPlayerIcon.js 1 month ago ProGateOverlay.js 1 month ago QuickAccess.js 1 month ago RankedTable.js 1 month ago StatCard.js 1 month ago TopMedia.js 1 month ago TopPerformingMedia.js 1 month ago TopUsers.js 1 month ago TruncatedTitle.js 1 month ago UpgradeNotice.js 1 month ago UpgradeToPro.js 1 month ago VideoModal.js 1 month ago WelcomeBanner.js 1 month ago
UpgradeNotice.js
125 lines
1 import { useState } from "react";
2 import { Button, Container } from "@bsf/force-ui";
3 import { X as XIcon } from "lucide-react";
4 import { useHistory } from "../router/router";
5 import useUpgradeCTA from "../hooks/useUpgradeCTA";
6
7 const { __ } = wp.i18n;
8
9 const COOKIE_NAME = "presto_player_upgrade_notice_seen";
10 const COOKIE_DAYS = 10;
11
12 const getCookie = (name) => {
13 const match = document.cookie.match(
14 new RegExp(
15 "(?:^|; )" + name.replace(/([.$?*|{}()[\]\\/+^])/g, "\\$1") + "=([^;]*)"
16 )
17 );
18 if (!match) {
19 return null;
20 }
21 try {
22 return decodeURIComponent(match[1]);
23 } catch {
24 return null;
25 }
26 };
27
28 const setCookie = (name, value, days) => {
29 const expires = new Date();
30 expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
31 const secure = window.location.protocol === "https:" ? "; Secure" : "";
32 document.cookie = `${name}=${encodeURIComponent(
33 value
34 )}; expires=${expires.toUTCString()}; path=/; SameSite=Lax${secure}`;
35 };
36
37 const UpgradeNotice = () => {
38 const [showNotice, setShowNotice] = useState(() => !getCookie(COOKIE_NAME));
39 const history = useHistory();
40 const {
41 label,
42 onClick,
43 isProUnlicensed,
44 isLicenseInvalid,
45 isPremium,
46 renewLink,
47 } = useUpgradeCTA(history);
48
49 if (isPremium) {
50 return null;
51 }
52
53 if (!showNotice) {
54 return null;
55 }
56
57 const handleClose = () => {
58 setShowNotice(false);
59 setCookie(COOKIE_NAME, "true", COOKIE_DAYS);
60 };
61
62 let lead;
63 if (isLicenseInvalid) {
64 lead = __(
65 "Your Presto Player Pro license has expired. Please renew to restore Pro Features, Premium Support & Automatic Plugin Updates.",
66 "presto-player"
67 );
68 } else if (isProUnlicensed) {
69 lead = __("Your Pro license isn't activated yet.", "presto-player");
70 } else {
71 lead = __("Ready to go beyond free plan?", "presto-player");
72 }
73
74 // The shared hook's defaults send unlicensed users to the in-app license tab.
75 // For an *invalid* key we instead want the primary CTA to renew (external)
76 // and surface a secondary "Buy Subscription" link as an alternative path.
77 const primaryLabel = isLicenseInvalid
78 ? __("Renew Now", "presto-player")
79 : label;
80 const primaryOnClick = isLicenseInvalid
81 ? (e) => {
82 e?.preventDefault?.();
83 window.open(renewLink, "_blank", "noopener noreferrer");
84 }
85 : onClick;
86
87 return (
88 <Container
89 className="relative bg-brand-background-hover-100 p-2 text-xs text-center gap-1"
90 align="center"
91 >
92 <p className="text-text-primary w-full lg:mx-0 m-0 p-0">
93 <span className="font-semibold text-xs">{lead}</span>{" "}
94 <Button
95 variant="link"
96 className="p-0 [&>span]:p-0 underline underline-offset-2 font-normal"
97 size="xs"
98 onClick={primaryOnClick}
99 >
100 {primaryLabel}
101 </Button>
102 {!isProUnlicensed && (
103 <span className="font-normal text-xs">
104 {" " +
105 __("and unlock the full power of", "presto-player") +
106 " Presto Player!"}
107 </span>
108 )}
109 </p>
110 <Container.Item className="absolute right-2 inset-y-0 inline-flex items-center">
111 <Button
112 variant="ghost"
113 size="xs"
114 className="p-1 hover:bg-transparent"
115 icon={<XIcon className="size-4" />}
116 onClick={handleClose}
117 aria-label={__("Dismiss upgrade notice", "presto-player")}
118 />
119 </Container.Item>
120 </Container>
121 );
122 };
123
124 export default UpgradeNotice;
125