Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add purchase button & license-key settings #176

Open
wants to merge 37 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4990581
Add a new widget with a purchase button
aristath Dec 10, 2024
dc9619c
Merge branch 'develop' into add/purchase-button
aristath Dec 10, 2024
de959fe
Add free-license field
aristath Dec 10, 2024
1749b7e
Save option
aristath Dec 10, 2024
117c9a0
Merge branch 'develop' into add/purchase-button
aristath Dec 11, 2024
2d7752d
Save the license.
aristath Dec 11, 2024
664c6ee
Merge remote-tracking branch 'origin/add/purchase-button' into add/pu…
aristath Dec 11, 2024
f5e4362
debug license saving
aristath Dec 11, 2024
88a8875
Tweak the license status display
aristath Dec 11, 2024
baba8b7
No need to show free license
aristath Dec 11, 2024
63809cd
cache empty array for 5 mins if we dont have valid resposne
ilicfilip Dec 11, 2024
41fde4c
Merge branch 'develop' into add/purchase-button
aristath Dec 11, 2024
444f112
check if $item is an array
ilicfilip Dec 11, 2024
7468821
Merge remote-tracking branch 'origin/add/purchase-button' into add/pu…
ilicfilip Dec 11, 2024
a3ad177
layout tweak
aristath Dec 11, 2024
2ab2f4d
improve the `is_pro_site()` method
aristath Dec 11, 2024
1326c0e
allow user to clear the license
ilicfilip Dec 11, 2024
763bdd9
Fix remote tasks
aristath Dec 11, 2024
55149ac
Merge branch 'develop' into add/purchase-button
aristath Dec 12, 2024
f036f67
Merge branch 'develop' into add/purchase-button
aristath Dec 13, 2024
b3d5398
prpl-pro-license-key field hidden when free license is not active
ilicfilip Dec 13, 2024
6ae8124
Avoid conditional changes to the structure
aristath Dec 13, 2024
d464462
Merge branch 'develop' into add/purchase-button
aristath Dec 13, 2024
d5968fc
Merge branch 'develop' into add/purchase-button
aristath Dec 13, 2024
2565943
Merge branch 'develop' into add/purchase-button
aristath Dec 13, 2024
139ea79
Merge branch 'develop' into add/purchase-button
aristath Dec 16, 2024
ca66d1c
Only init Page_Todos is this is a pro site, otherwise we don't need it
aristath Dec 16, 2024
edc8bdf
Rename "start"/"end" to "start_date"/"end_date"
aristath Dec 17, 2024
0055d86
Convert anonymous method to normal method
aristath Dec 17, 2024
9f08e68
Merge branch 'develop' into add/purchase-button
aristath Dec 17, 2024
06b032d
Merge branch 'develop' into add/purchase-button
aristath Dec 18, 2024
eb30a00
Change how the widget is rendered conditionally
aristath Dec 18, 2024
2315ec3
Change the classname
aristath Dec 18, 2024
57c8049
CS fix
aristath Dec 18, 2024
081fba5
Merge branch 'develop' into add/purchase-button
aristath Dec 18, 2024
6539189
Merge branch 'develop' into add/purchase-button
ilicfilip Jan 6, 2025
1dcf552
shortlink for the button link
aristath Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions assets/css/page-widgets/get-pro.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.button-get-pro-link {
display: block;
width: 100%;
padding: 0.5rem 1rem;
background-color: var(--prpl-color-accent-red);
color: #fff !important;
font-weight: 600;
text-decoration: none;
text-align: center;
border-radius: 0.25rem;
box-sizing: border-box;
font-size: var(--prpl-font-size-xl);
border: 2px solid transparent;
outline: 2px solid transparent;
transition: all 0.2s ease-in-out;

&:hover {
outline: 2px solid var(--prpl-color-accent-red);
}
}
27 changes: 27 additions & 0 deletions assets/css/settings-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,30 @@
gap: 3rem;
}
}

.prpl-license-keys-wrapper {
display: flex;
flex-direction: column;
gap: 1rem;

.prpl-license-key-wrapper {
display: flex;
align-items: center;
gap: 0.5rem;

.prpl-license-status {
width: 1rem;
height: 1rem;

svg {
width: 1rem;
height: 1rem;
}
}
}

input {
width: 20rem;
max-width: calc(100% - 2rem);
}
}
14 changes: 12 additions & 2 deletions assets/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ if ( !! settingsLicenseForm ) {

// Timeout so the license key is saved.
setTimeout( () => {
// Reload the page.
window.location.reload();
// Reload the page and remove `#prpl-popover-subscribe-form-trigger` from the URL.
window.location.href =
window.location.href.replace(
'#prpl-popover-subscribe-form-trigger',
''
);
}, 500 );
},
failAction: ( apiResponse ) => {
Expand All @@ -77,3 +81,9 @@ if ( !! settingsLicenseForm ) {
progressPlanner.l10n.subscribing;
} );
}

// Check if the URL has #prpl-popover-subscribe-form-trigger.
if ( window.location.hash === '#prpl-popover-subscribe-form-trigger' ) {
// Show the popover.
document.querySelector( '#prpl-popover-subscribe-form-trigger' ).click();
}
1 change: 1 addition & 0 deletions classes/admin/class-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function get_widgets() {
\progress_planner()->get_widgets__badge_streak(),
\progress_planner()->get_widgets__published_content(),
\progress_planner()->get_widgets__whats_new(),
\progress_planner()->get_widgets__get_pro(),
];

/**
Expand Down
4 changes: 3 additions & 1 deletion classes/class-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ public function init() {
$this->cached['todo'] = new Todo();

// Post-meta.
$this->cached['page_todos'] = new Page_Todos();
if ( $this->is_pro_site() ) {
$this->cached['page_todos'] = new Page_Todos();
}

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

Expand Down
4 changes: 4 additions & 0 deletions classes/suggested-tasks/class-remote-tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public function get_tasks_to_inject() {
}
}
}

// 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.
\progress_planner()->get_cache()->set( self::CACHE_KEY, [], 5 * MINUTE_IN_SECONDS );

return [];
}

Expand Down
33 changes: 33 additions & 0 deletions classes/widgets/class-get-pro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* A widget class.
*
* @package Progress_Planner
*/

namespace Progress_Planner\Widgets;

/**
* Get_Pro class.
*/
final class Get_Pro extends \Progress_Planner\Widget {

/**
* The widget ID.
*
* @var string
*/
protected $id = 'get-pro';

/**
* Render the widget.
*
* @return void
*/
public function render() {
if ( \progress_planner()->is_pro_site() ) {
return;
}
parent::render();
}
}
2 changes: 1 addition & 1 deletion views/admin-page-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</div>
</div>

<div class="prpl-column" style="display:none;">
<div class="prpl-column">
<div class="prpl-widget-wrapper">
<h2 class="prpl-settings-section-license">
<span>
Expand Down
16 changes: 16 additions & 0 deletions views/page-widgets/get-pro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Widget view.
*
* @package Progress_Planner
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

?>

<a class="button-get-pro-link" href="https://progressplanner.com/buy-pro" target="_blank">
<?php \esc_html_e( 'Get PRO', 'progress-planner' ); ?>
</a>
Loading