Skip to content

Commit 6314127

Browse files
authored
Merge pull request #176 from Emilia-Capital/add/purchase-button
Add license-key settings
2 parents cbb5390 + cb239ae commit 6314127

File tree

6 files changed

+98
-14
lines changed

6 files changed

+98
-14
lines changed

assets/css/admin.css

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,23 +283,53 @@ button.prpl-info-icon {
283283
.prpl-wrap input.prpl-button-primary,
284284
.prpl-wrap input.prpl-button-secondary,
285285
.prpl-wrap button.prpl-button-primary,
286-
.prpl-wrap button.prpl-button-secondary {
286+
.prpl-wrap button.prpl-button-secondary,
287+
.prpl-wrap a.prpl-button-primary,
288+
.prpl-wrap a.prpl-button-secondary {
287289
display: block;
288-
margin: 1em 0;
289-
padding: 1em;
290+
margin: 1rem 0;
291+
padding: 0.75rem 1.25rem;
290292
color: #fff;
291293
text-decoration: none;
292294
cursor: pointer;
293295
font-size: var(--prpl-font-size-base);
294296
background: var(--prpl-color-accent-red);
297+
line-height: 1.25;
295298
box-shadow: none;
296299
border: none;
297-
border-radius: var(--prpl-border-radius);
300+
border-radius: 6px;
301+
transition: all 0.25s ease-in-out;
302+
font-weight: 600;
303+
text-align: center;
304+
box-sizing: border-box;
305+
position: relative;
306+
z-index: 1;
307+
308+
&::after {
309+
content: "";
310+
display: block;
311+
width: 100%;
312+
height: 100%;
313+
background: var(--prpl-color-accent-red);
314+
position: absolute;
315+
top: 0;
316+
left: 0;
317+
z-index: -1;
318+
border-radius: 6px;
319+
transition: all 0.25s ease-in-out;
320+
}
298321

299322
&:hover,
300323
&:focus {
301-
text-decoration: underline;
302-
box-shadow: 3px 3px 10px var(--prpl-color-accent-red);
324+
background: #cf2441;
325+
326+
&::after {
327+
background: #cf2441;
328+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
329+
width: calc(100% + 4px);
330+
height: calc(100% + 4px);
331+
margin: -2px;
332+
}
303333
}
304334
}
305335

assets/css/settings-page.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,30 @@
222222
gap: 3rem;
223223
}
224224
}
225+
226+
.prpl-license-keys-wrapper {
227+
display: flex;
228+
flex-direction: column;
229+
gap: 1rem;
230+
231+
.prpl-license-key-wrapper {
232+
display: flex;
233+
align-items: center;
234+
gap: 0.5rem;
235+
236+
.prpl-license-status {
237+
width: 1rem;
238+
height: 1rem;
239+
240+
svg {
241+
width: 1rem;
242+
height: 1rem;
243+
}
244+
}
245+
}
246+
247+
input {
248+
width: 20rem;
249+
max-width: calc(100% - 2rem);
250+
}
251+
}

assets/js/settings.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ if ( !! settingsLicenseForm ) {
5959

6060
// Timeout so the license key is saved.
6161
setTimeout( () => {
62-
// Reload the page.
63-
window.location.reload();
62+
// Reload the page and remove `#prpl-popover-subscribe-form-trigger` from the URL.
63+
window.location.href =
64+
window.location.href.replace(
65+
'#prpl-popover-subscribe-form-trigger',
66+
''
67+
);
6468
}, 500 );
6569
},
6670
failAction: ( apiResponse ) => {
@@ -77,3 +81,9 @@ if ( !! settingsLicenseForm ) {
7781
progressPlanner.l10n.subscribing;
7882
} );
7983
}
84+
85+
// Check if the URL has #prpl-popover-subscribe-form-trigger.
86+
if ( window.location.hash === '#prpl-popover-subscribe-form-trigger' ) {
87+
// Show the popover.
88+
document.querySelector( '#prpl-popover-subscribe-form-trigger' ).click();
89+
}

classes/class-base.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ public function init() {
8686
$this->cached['todo'] = new Todo();
8787

8888
// Post-meta.
89-
$this->cached['page_todos'] = new Page_Todos();
89+
if ( $this->is_pro_site() ) {
90+
$this->cached['page_todos'] = new Page_Todos();
91+
}
9092

9193
\add_filter( 'plugin_action_links_' . plugin_basename( PROGRESS_PLANNER_FILE ), [ $this, 'add_action_links' ] );
9294

classes/suggested-tasks/class-remote-tasks.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public function get_tasks_to_inject() {
8686
}
8787
}
8888
}
89+
90+
// If we don't have a valid response, cache an empty array for 5 minutes. This will prevent the API from being called too often.
91+
\progress_planner()->get_cache()->set( self::CACHE_KEY, [], 5 * MINUTE_IN_SECONDS );
92+
8993
return [];
9094
}
9195

views/admin-page-settings.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@
5656
</div>
5757
</div>
5858

59-
<div class="prpl-column" style="display:none;">
59+
<div class="prpl-column">
6060
<div class="prpl-widget-wrapper">
6161
<h2 class="prpl-settings-section-license">
6262
<span>
63-
<?php \esc_html_e( 'Licenses', 'progress-planner' ); ?>
63+
<?php \esc_html_e( 'License', 'progress-planner' ); ?>
6464
</span>
6565
</h2>
6666
<div class="prpl-license-keys-wrapper">
@@ -78,13 +78,24 @@
7878
<?php endif ?>
7979

8080
<div style="<?php echo ( '' === $prpl_free_license_key ) ? 'display: none;' : ''; ?>">
81-
<label for="prpl-setting-pro-license-key">
82-
<?php \esc_html_e( 'Progress Planner Pro license key', 'progress-planner' ); ?>
83-
</label>
8481
<?php
8582
$prpl_pro_license = \get_option( 'progress_planner_pro_license_key', '' );
8683
$prpl_pro_license_status = \get_option( 'progress_planner_pro_license_status', '' );
8784
?>
85+
<?php if ( empty( $prpl_pro_license ) || 'valid' !== $prpl_pro_license_status ) : ?>
86+
<p>
87+
<?php
88+
printf(
89+
// translators: %s is a link to the Pro page, with the text "Progress Planner Pro".
90+
\esc_html__( 'Take part in interactive challenges to solve website problems like broken links and sharpen your skills with in-context mini courses. Upgrade to %s!', 'progress-planner' ),
91+
'<a href="https://progressplanner.com/pro/" target="_blank">Progress Planner Pro</a>'
92+
);
93+
?>
94+
</p>
95+
<?php endif; ?>
96+
<label for="prpl-setting-pro-license-key">
97+
<?php \esc_html_e( 'Progress Planner Pro license key', 'progress-planner' ); ?>
98+
</label>
8899
<div class="prpl-license-key-wrapper">
89100
<input
90101
id="prpl-setting-pro-license-key"

0 commit comments

Comments
 (0)