PluginProbe
Print, PDF & Email by PrintFriendly / 5.5.13
Print, PDF & Email by PrintFriendly v5.5.13
5.5.13 5.5.12 5.5.11 trunk 0.2 0.9 1.0 2.0 2.1.8 3.0 3.0.9 3.1.6 3.10.0 3.11.0 3.11.1 3.11.2 3.12.0 3.12.1 3.12.2 3.12.3 3.12.4 3.12.5 3.13.0 3.14.0 3.14.1 All 95 releases
printfriendly / views / pro-card.php

pro-card.php in Print, PDF & Email by PrintFriendly 5.5.13, at views/pro-card.php

354 lines 22.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Pro card v2. Included from PrintFriendly_Pro_Card::render() with $card set
5 * by PrintFriendly_Pro_Card::view_model(). Only rendered when the
6 * PRINTFRIENDLY_PRO_CARD_V2 flag is on; views/pro.php is the default.
7 *
8 * Copy rules: no em dashes, never WordPress core's plugin verb for the trial
9 * action, and the yellow button is always last in the action row so it sits
10 * on the right.
11 */
12
13 if (! defined('ABSPATH')) {
14 exit;
15 }
16 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included from PrintFriendly_Pro_Card::render(); $card is method-scoped, not global.
17
18 $pf_state = $card['state'];
19 $pf_pills = array(
20 'offer' => array('free', __('Free plan', 'printfriendly')),
21 'free' => array('free', __('Free plan', 'printfriendly')),
22 'free_connected' => array('free', __('Free plan', 'printfriendly')),
23 'expired' => array('free', __('Free plan', 'printfriendly')),
24 'expired_eligible' => array('free', __('Free plan', 'printfriendly')),
25 'trial' => array('trial', __('Pro trial', 'printfriendly')),
26 'pro' => array('pro', __('Pro', 'printfriendly')),
27 'past_due' => array('pastdue', __('Payment failed', 'printfriendly')),
28 'cancelled' => array('cancelled', __('Pro ending', 'printfriendly')),
29 );
30 $pf_pill = isset($pf_pills[$pf_state]) ? $pf_pills[$pf_state] : $pf_pills['free'];
31
32 $pf_notices = array(
33 'connected' => array('success', __('Connected. Your plan status now comes straight from your PrintFriendly account.', 'printfriendly')),
34 'pending' => array('info', __('The setup on printfriendly.com is not finished yet. The button below takes you back to it.', 'printfriendly')),
35 'handoff_failed' => array('error', __('We could not finish connecting this site. Try again, or email support@printfriendly.com.', 'printfriendly')),
36 'start_failed' => array('error', __('We could not reach PrintFriendly. Please try again in a minute.', 'printfriendly')),
37 'refreshed' => array('success', __('Status updated.', 'printfriendly')),
38 );
39
40 /**
41 * "We could not reach PrintFriendly" is only true when nothing answered. A
42 * server that answered with a status is a different failure and points
43 * somewhere else: a 404 in particular means the address is wrong, not that
44 * PrintFriendly is down, and reading it as an outage has cost real debugging
45 * time more than once. The status is on hand, so say it.
46 */
47 if ($card['notice'] === 'start_failed' && ! empty($card['notice_status'])) {
48 $pf_status = (int) $card['notice_status'];
49 if ($pf_status === 404) {
50 /* translators: %s: the API address the plugin is calling, for example https://www.printfriendly.com */
51 $pf_start_failed = sprintf(__('PrintFriendly answered from %s but has no page there (HTTP 404). That usually means the API address is wrong rather than PrintFriendly being down.', 'printfriendly'), PrintFriendly_Pro_Card::api_base());
52 } else {
53 /* translators: 1: HTTP status code, for example 503, 2: the API address the plugin is calling */
54 $pf_start_failed = sprintf(__('PrintFriendly returned HTTP %1$d from %2$s. Please try again in a minute.', 'printfriendly'), $pf_status, PrintFriendly_Pro_Card::api_base());
55 }
56 // Only the message: the severity stays owned by the array above, so
57 // changing 'error' there is not silently undone here.
58 $pf_notices['start_failed'][1] = $pf_start_failed;
59 }
60
61 /* translators: %s: the site's domain name */
62 $pf_live_on = sprintf(__('Live on %s', 'printfriendly'), $card['host']);
63 /* translators: %s: the email address of the connected PrintFriendly account */
64 $pf_connected_as = sprintf(__('Connected as %s', 'printfriendly'), $card['account_email']);
65 $pf_why_pro = __('Free works forever, but readers finish on printfriendly.com, where the ads are. Pro opens the preview on your own pages, ad-free.', 'printfriendly');
66 /* translators: 1: price line, for example "$8.25 a month, billed yearly", 2: the yearly charge, for example "$99" */
67 $pf_trial_terms = sprintf(__('30-day trial, card required, nothing charged today. Then %1$s at %2$s. Cancel anytime.', 'printfriendly'), $card['price_line'], $card['charge_amount']);
68 ?>
69 <div id="pf-pro-card" class="pf-bu-block pf-card pf-card-state-<?php echo esc_attr($pf_state); ?>" data-state="<?php echo esc_attr($pf_state); ?>">
70
71 <?php if ($card['stub']) { ?>
72 <div class="pf-card-stub">
73 <strong><?php esc_html_e('Stub mode', 'printfriendly'); ?></strong>
74 <span><?php esc_html_e('PRINTFRIENDLY_API_STUB is on. No request leaves this site. Pick a state to preview it:', 'printfriendly'); ?></span>
75 <label for="pf-stub-state" class="screen-reader-text"><?php esc_html_e('Stub state', 'printfriendly'); ?></label>
76 <select id="pf-stub-state" data-url="<?php echo esc_url($card['stub_url']); ?>">
77 <?php foreach ($card['stub_states'] as $pf_stub_state) { ?>
78 <option value="<?php echo esc_attr($pf_stub_state); ?>" <?php selected($card['stub_state'], $pf_stub_state); ?>><?php echo esc_html($pf_stub_state); ?></option>
79 <?php } ?>
80 </select>
81 </div>
82 <?php } ?>
83
84 <?php if ($card['notice'] && isset($pf_notices[$card['notice']])) { ?>
85 <div class="pf-card-notice pf-card-notice-<?php echo esc_attr($pf_notices[$card['notice']][0]); ?>" role="status">
86 <?php echo esc_html($pf_notices[$card['notice']][1]); ?>
87 </div>
88 <?php } ?>
89
90 <?php if ($card['unreachable']) { ?>
91 <div class="pf-card-notice pf-card-notice-warning" role="status">
92 <?php esc_html_e('We could not reach PrintFriendly to check your plan. Your button keeps working either way.', 'printfriendly'); ?>
93 <a href="<?php echo esc_url($card['refresh_url']); ?>"><?php esc_html_e('Try again', 'printfriendly'); ?></a>
94 </div>
95 <?php } elseif ($card['stale']) { ?>
96 <div class="pf-card-notice pf-card-notice-warning" role="status">
97 <?php esc_html_e('We could not reach PrintFriendly just now, so this is the last status we saw.', 'printfriendly'); ?>
98 <a href="<?php echo esc_url($card['refresh_url']); ?>"><?php esc_html_e('Try again', 'printfriendly'); ?></a>
99 </div>
100 <?php } ?>
101
102 <?php if ($pf_state === 'offer') { ?>
103 <div class="pf-card-offer">
104 <div class="pf-card-offer-copy">
105 <div class="pf-card-status">
106 <span class="pf-card-pill pf-card-pill-<?php echo esc_attr($pf_pill[0]); ?>"><?php echo esc_html($pf_pill[1]); ?></span>
107 <span class="pf-card-context"><?php echo esc_html($pf_live_on); ?></span>
108 </div>
109 <h2 class="pf-card-headline pf-card-headline-lg"><?php esc_html_e('Remove the ads. Keep users on your site.', 'printfriendly'); ?></h2>
110 <p class="pf-card-line pf-card-line-lg"><?php echo esc_html($pf_why_pro); ?></p>
111 <p class="pf-card-line pf-card-line-sm">
112 <?php
113 echo wp_kses(
114 sprintf(
115 /* translators: 1: the site's domain name, 2: the admin email address */
116 __('We will set this up for %1$s using %2$s. You can change either on the next screen.', 'printfriendly'),
117 '<strong>' . esc_html($card['host']) . '</strong>',
118 '<strong>' . esc_html($card['admin_email']) . '</strong>'
119 ),
120 array('strong' => array())
121 );
122 ?>
123 </p>
124 <div class="pf-card-actions">
125 <a class="pf-card-btn pf-card-btn-ghost" href="<?php echo esc_url($card['stay_free_url']); ?>"><?php esc_html_e('Keep the free plan', 'printfriendly'); ?></a>
126 <a class="pf-card-btn pf-card-btn-yellow pf-card-btn-lg" href="<?php echo esc_url($card['start_url']); ?>" data-busy="<?php esc_attr_e('Opening PrintFriendly', 'printfriendly'); ?>"><?php esc_html_e('Remove ads now, free for 30 days', 'printfriendly'); ?></a>
127 </div>
128 <p class="pf-card-fine"><?php echo esc_html($pf_trial_terms); ?></p>
129 </div>
130
131 <div class="pf-card-offer-visual" aria-hidden="true">
132 <div class="pf-card-badge">
133 <span class="pf-card-badge-dot"><svg width="11" height="11" viewBox="0 0 16 16" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 8.5 L6.5 12 L13 4.5"></path></svg></span>
134 <span class="pf-card-badge-text"><?php esc_html_e('Ad-free, on your site', 'printfriendly'); ?></span>
135 </div>
136 <div class="pf-card-mock">
137 <div class="pf-card-mock-bar">
138 <i></i><i></i><i></i>
139 <span class="pf-card-mock-url"><?php echo esc_html($card['host'] . $card['sample_path']); ?></span>
140 </div>
141 <div class="pf-card-mock-page">
142 <div class="pf-card-mock-skel" style="width:70%"></div>
143 <div class="pf-card-mock-skel"></div>
144 <div class="pf-card-mock-preview">
145 <div class="pf-card-mock-chips">
146 <span class="is-on"><?php esc_html_e('Print', 'printfriendly'); ?></span>
147 <span><?php esc_html_e('PDF', 'printfriendly'); ?></span>
148 <span><?php esc_html_e('Email', 'printfriendly'); ?></span>
149 </div>
150 <div class="pf-card-mock-rule"></div>
151 <div class="pf-card-mock-title"></div>
152 <div class="pf-card-mock-skel"></div>
153 <div class="pf-card-mock-skel"></div>
154 <div class="pf-card-mock-skel" style="width:76%"></div>
155 <div class="pf-card-mock-skel" style="width:90%"></div>
156 </div>
157 </div>
158 </div>
159 <p class="pf-card-mock-caption"><?php esc_html_e('What your readers see on Pro. Your address stays in the bar, nothing else on screen.', 'printfriendly'); ?></p>
160 </div>
161 </div>
162 <?php } else { ?>
163 <div class="pf-card-status">
164 <span class="pf-card-pill pf-card-pill-<?php echo esc_attr($pf_pill[0]); ?>"><?php echo esc_html($pf_pill[1]); ?></span>
165 <span class="pf-card-context">
166 <?php
167 switch ($pf_state) {
168 case 'free':
169 echo esc_html($pf_live_on);
170 break;
171 case 'expired':
172 if ($card['last_trial_date']) {
173 /* translators: %s: a date */
174 echo esc_html(sprintf(__('Your Pro trial ended on %s. Nothing broke and nothing was charged.', 'printfriendly'), $card['last_trial_date']));
175 } else {
176 esc_html_e('Your Pro trial has ended. Nothing broke and nothing was charged.', 'printfriendly');
177 }
178 break;
179 case 'expired_eligible':
180 if ($card['last_trial_date']) {
181 /* translators: %s: a date */
182 echo esc_html(sprintf(__('Your last trial ended on %s. Nothing was ever charged.', 'printfriendly'), $card['last_trial_date']));
183 } else {
184 esc_html_e('Your last trial has ended. Nothing was ever charged.', 'printfriendly');
185 }
186 break;
187 default:
188 echo esc_html($pf_connected_as);
189 }
190 ?>
191 </span>
192 </div>
193
194 <?php if ($pf_state === 'free' || $pf_state === 'free_connected') { ?>
195 <?php /* translators: %s: the site's domain name */ ?>
196 <h2 class="pf-card-headline"><?php echo esc_html(sprintf(__('Your button is live on %s.', 'printfriendly'), $card['host'])); ?></h2>
197 <p class="pf-card-line"><?php echo esc_html($pf_why_pro); ?></p>
198 <div class="pf-card-actions">
199 <?php if ($card['eligible']) { ?>
200 <a class="pf-card-btn pf-card-btn-yellow" href="<?php echo esc_url($card['start_url']); ?>" data-busy="<?php esc_attr_e('Opening PrintFriendly', 'printfriendly'); ?>"><?php esc_html_e('Remove ads now, free for 30 days', 'printfriendly'); ?></a>
201 <?php } else { ?>
202 <a class="pf-card-btn pf-card-btn-yellow" href="<?php echo esc_url($card['buy_url']); ?>" data-busy="<?php esc_attr_e('Opening PrintFriendly', 'printfriendly'); ?>"><?php esc_html_e('Remove ads now', 'printfriendly'); ?></a>
203 <?php } ?>
204 </div>
205 <p class="pf-card-fine">
206 <?php
207 if ($card['eligible']) {
208 echo esc_html($pf_trial_terms);
209 } else {
210 /* translators: 1: price line, 2: the yearly charge, for example "$99" */
211 echo esc_html(sprintf(__('%1$s at %2$s. Cancel anytime.', 'printfriendly'), $card['price_line'], $card['charge_amount']));
212 }
213 ?>
214 </p>
215
216 <?php } elseif ($pf_state === 'trial') { ?>
217 <h2 class="pf-card-headline">
218 <?php
219 if ($card['days_left'] === null) {
220 esc_html_e('Ads are off. Your Pro trial is running.', 'printfriendly');
221 } elseif ($card['days_left'] === 0) {
222 esc_html_e('Ads are off. Your trial ends today.', 'printfriendly');
223 } else {
224 /* translators: %d: number of days left in the trial */
225 echo esc_html(sprintf(_n('Ads are off. %d day left in your trial.', 'Ads are off. %d days left in your trial.', $card['days_left'], 'printfriendly'), $card['days_left']));
226 }
227 ?>
228 </h2>
229 <p class="pf-card-line">
230 <?php esc_html_e('Readers now finish on your own pages, ad-free.', 'printfriendly'); ?>
231 <?php if ($card['dev_domain'] !== '') { ?>
232 <?php /* translators: %s: a development domain name */ ?>
233 <?php echo esc_html(sprintf(__('Development domain %s is included.', 'printfriendly'), $card['dev_domain'])); ?>
234 <?php } ?>
235 </p>
236 <div class="pf-card-actions">
237 <a class="pf-card-btn pf-card-btn-secondary" href="<?php echo esc_url($card['account_url']); ?>" target="_blank" rel="noopener"><?php esc_html_e('View account', 'printfriendly'); ?></a>
238 </div>
239 <p class="pf-card-fine"><?php esc_html_e('Your button settings stay right here in the plugin.', 'printfriendly'); ?></p>
240
241 <?php } elseif ($pf_state === 'expired') { ?>
242 <h2 class="pf-card-headline"><?php esc_html_e('The ads are back on your button.', 'printfriendly'); ?></h2>
243 <p class="pf-card-line"><?php esc_html_e('Readers finish on printfriendly.com again. Pro puts the preview back on your own pages, ad-free, and picks up right where you left off.', 'printfriendly'); ?></p>
244 <div class="pf-card-actions">
245 <a class="pf-card-btn pf-card-btn-ghost" href="<?php echo esc_url($card['stay_free_url']); ?>"><?php esc_html_e('Stay on Free', 'printfriendly'); ?></a>
246 <a class="pf-card-btn pf-card-btn-yellow" href="<?php echo esc_url($card['buy_url']); ?>" data-busy="<?php esc_attr_e('Opening PrintFriendly', 'printfriendly'); ?>"><?php esc_html_e('Remove ads now', 'printfriendly'); ?></a>
247 </div>
248 <?php /* translators: 1: price line, 2: the yearly charge, for example "$99" */ ?>
249 <p class="pf-card-fine"><?php echo esc_html(sprintf(__('%1$s at %2$s. Cancel anytime. Your card was never charged during the trial.', 'printfriendly'), $card['price_line'], $card['charge_amount'])); ?></p>
250
251 <?php } elseif ($pf_state === 'expired_eligible') { ?>
252 <h2 class="pf-card-headline"><?php esc_html_e('Try Pro again, free for 30 days.', 'printfriendly'); ?></h2>
253 <p class="pf-card-line"><?php esc_html_e('You are eligible for another trial. Pro puts the preview back on your own pages, ad-free, and remembers every setting from last time.', 'printfriendly'); ?></p>
254 <div class="pf-card-actions">
255 <a class="pf-card-btn pf-card-btn-ghost" href="<?php echo esc_url($card['stay_free_url']); ?>"><?php esc_html_e('Stay on Free', 'printfriendly'); ?></a>
256 <a class="pf-card-btn pf-card-btn-yellow" href="<?php echo esc_url($card['start_url']); ?>" data-busy="<?php esc_attr_e('Opening PrintFriendly', 'printfriendly'); ?>"><?php esc_html_e('Try Pro again, free', 'printfriendly'); ?></a>
257 </div>
258 <?php /* translators: 1: price line, 2: the yearly charge, for example "$99" */ ?>
259 <p class="pf-card-fine"><?php echo esc_html(sprintf(__('Card required, nothing charged today. Then %1$s at %2$s. Cancel anytime.', 'printfriendly'), $card['price_line'], $card['charge_amount'])); ?></p>
260
261 <?php } elseif ($pf_state === 'pro') { ?>
262 <?php /* translators: %s: the site's domain name */ ?>
263 <h2 class="pf-card-headline"><?php echo esc_html(sprintf(__('Pro is active on %s.', 'printfriendly'), $card['host'])); ?></h2>
264 <p class="pf-card-line">
265 <?php esc_html_e('Readers finish on your own pages, ad-free.', 'printfriendly'); ?>
266 <?php if ($card['dev_domain'] !== '') { ?>
267 <?php /* translators: %s: a development domain name */ ?>
268 <?php echo esc_html(sprintf(__('Development domain %s is included.', 'printfriendly'), $card['dev_domain'])); ?>
269 <?php } ?>
270 </p>
271 <div class="pf-card-actions">
272 <a class="pf-card-btn pf-card-btn-secondary" href="<?php echo esc_url($card['account_url']); ?>" target="_blank" rel="noopener"><?php esc_html_e('View account', 'printfriendly'); ?></a>
273 </div>
274 <p class="pf-card-fine"><?php esc_html_e('Your button settings stay right here in the plugin.', 'printfriendly'); ?></p>
275
276 <?php } elseif ($pf_state === 'past_due') { ?>
277 <h2 class="pf-card-headline"><?php esc_html_e('We could not charge your card.', 'printfriendly'); ?></h2>
278 <p class="pf-card-line">
279 <strong>
280 <?php
281 if ($card['grace_date']) {
282 /* translators: %s: a date */
283 echo esc_html(sprintf(__('Pro stays on until %s.', 'printfriendly'), $card['grace_date']));
284 } else {
285 esc_html_e('Pro stays on for now.', 'printfriendly');
286 }
287 ?>
288 </strong>
289 <?php esc_html_e('Update your card by then to keep it. If we still cannot charge it, your button drops back to Free and the ads come back. Nothing else happens.', 'printfriendly'); ?>
290 </p>
291 <div class="pf-card-actions">
292 <a class="pf-card-btn pf-card-btn-ghost" href="<?php echo esc_url($card['support_url']); ?>"><?php esc_html_e('Contact support', 'printfriendly'); ?></a>
293 <a class="pf-card-btn pf-card-btn-yellow" href="<?php echo esc_url($card['update_card_url']); ?>" target="_blank" rel="noopener"><?php esc_html_e('Update card', 'printfriendly'); ?></a>
294 </div>
295 <p class="pf-card-fine">
296 <?php
297 if ($card['failed_date']) {
298 /* translators: 1: a date, 2: price line, for example "$8.25 a month, billed yearly" */
299 echo esc_html(sprintf(__('We tried %1$s and will retry twice more. We never charge more than %2$s.', 'printfriendly'), $card['failed_date'], $card['price_line']));
300 } else {
301 /* translators: %s: price line, for example "$8.25 a month, billed yearly" */
302 echo esc_html(sprintf(__('We will retry twice more. We never charge more than %s.', 'printfriendly'), $card['price_line']));
303 }
304 ?>
305 </p>
306
307 <?php } elseif ($pf_state === 'cancelled') { ?>
308 <h2 class="pf-card-headline">
309 <?php
310 if ($card['ends_date']) {
311 /* translators: %s: a date */
312 echo esc_html(sprintf(__('Pro ends on %s.', 'printfriendly'), $card['ends_date']));
313 } else {
314 esc_html_e('Pro ends at the end of this billing period.', 'printfriendly');
315 }
316 ?>
317 </h2>
318 <p class="pf-card-line">
319 <?php
320 if ($card['ends_date']) {
321 /* translators: %s: a date */
322 echo esc_html(sprintf(__('You cancelled, so nothing else is charged. On %s your button drops back to Free: it keeps working, the ads come back, and readers finish on printfriendly.com again.', 'printfriendly'), $card['ends_date']));
323 } else {
324 esc_html_e('You cancelled, so nothing else is charged. After that your button drops back to Free: it keeps working, the ads come back, and readers finish on printfriendly.com again.', 'printfriendly');
325 }
326 ?>
327 </p>
328 <div class="pf-card-actions">
329 <a class="pf-card-btn pf-card-btn-ghost" href="<?php echo esc_url($card['account_url']); ?>" target="_blank" rel="noopener"><?php esc_html_e('View account', 'printfriendly'); ?></a>
330 <a class="pf-card-btn pf-card-btn-yellow" href="<?php echo esc_url($card['resume_url']); ?>" target="_blank" rel="noopener"><?php esc_html_e('Keep Pro instead', 'printfriendly'); ?></a>
331 </div>
332 <p class="pf-card-fine"><?php esc_html_e('Changed your mind later? Pro picks up right where you left off.', 'printfriendly'); ?></p>
333 <?php } ?>
334 <?php } ?>
335
336 <div class="pf-card-rule"></div>
337 <div class="pf-card-footer">
338 <span>
339 <?php esc_html_e('PrintFriendly Pro is GDPR compliant.', 'printfriendly'); ?>
340 <a href="<?php echo esc_url($card['privacy_url']); ?>" target="_blank" rel="noopener"><?php esc_html_e('Privacy policy', 'printfriendly'); ?></a>
341 </span>
342 <?php if (in_array($pf_state, array('offer', 'free'), true)) { ?>
343 <span>
344 <?php esc_html_e('Questions?', 'printfriendly'); ?>
345 <a href="<?php echo esc_url($card['support_url']); ?>"><?php echo esc_html(PrintFriendly_Pro_Card::SUPPORT_EMAIL); ?></a>
346 </span>
347 <?php } else { ?>
348 <span>
349 <a href="<?php echo esc_url($card['refresh_url']); ?>"><?php esc_html_e('Refresh status', 'printfriendly'); ?></a>
350 </span>
351 <?php } ?>
352 </div>
353 </div>
354