Skip to content

Commit

Permalink
Merge branch 'develop' into filip/prototype-yoast-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ilicfilip committed Dec 20, 2024
2 parents 681e039 + 00d6b95 commit 554d635
Show file tree
Hide file tree
Showing 51 changed files with 303 additions and 210 deletions.
26 changes: 8 additions & 18 deletions assets/js/onboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@ const progressPlannerAjaxAPIRequest = ( data ) => {
data,
successAction: ( response ) => {
// Show success message.
if ( 'no-license' === response.license_key ) {
document.getElementById(
'prpl-account-not-created-message'
).style.display = 'block';
} else {
document.getElementById(
'prpl-account-created-message'
).style.display = 'block';
}
document.getElementById(
'no-license' === response.license_key
? 'prpl-account-not-created-message'
: 'prpl-account-created-message'
).style.display = 'block';

// Hide the form.
document.getElementById( 'prpl-onboarding-form' ).style.display =
Expand Down Expand Up @@ -119,15 +115,9 @@ if ( document.getElementById( 'prpl-onboarding-form' ) ) {
.addEventListener( 'change', function () {
const privacyPolicyAccepted = !! this.checked;

if ( privacyPolicyAccepted ) {
document.getElementById(
'prpl-onboarding-submit-wrapper'
).style.display = 'block';
} else {
document.getElementById(
'prpl-onboarding-submit-wrapper'
).style.display = 'none';
}
document.getElementById(
'prpl-onboarding-submit-wrapper'
).style.display = privacyPolicyAccepted ? 'block' : 'none';
} );

document
Expand Down
12 changes: 5 additions & 7 deletions assets/js/tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,11 @@ function prplStartTour() {
const urlParams = new URLSearchParams( window.location.search );
const savedStepIndex = urlParams.get( 'tour_step' );

if ( null !== savedStepIndex ) {
// Start from saved step.
prplDriverObj.drive( parseInt( savedStepIndex, 10 ) );
} else {
// Start from beginning.
prplDriverObj.drive( 0 );
}
prplDriverObj.drive(
null !== savedStepIndex
? parseInt( savedStepIndex, 10 ) // Start from saved step.
: 0 // Start from beginning.
);

// Remove `content-scan-finished=true` from the URL, without refreshing the page.
window.history.replaceState(
Expand Down
9 changes: 4 additions & 5 deletions assets/js/web-components/prpl-chart-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ customElements.define(
"></div>`;
// Only display up to 6 labels.
html += `<span class="label-container" style="height:1rem;overflow:visible;text-align:center;display:block;width:100%;font-size: 0.75em;">`;
if ( i % labelsDivider === 0 ) {
html += `<span class="label visible">${ item.label }</span>`;
} else {
html += `<span class="label invisible" style="visibility: hidden;">${ item.label }</span>`;
}
html +=
i % labelsDivider === 0
? `<span class="label visible">${ item.label }</span>`
: `<span class="label invisible" style="visibility: hidden;">${ item.label }</span>`;
html += `</span>`;
html += `</div>`;
i++;
Expand Down
56 changes: 29 additions & 27 deletions assets/js/widgets/suggested-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,36 +109,38 @@ const progressPlannerInjectSuggestedTodoItem = ( details ) => {
document
.querySelector( '.prpl-suggested-tasks-list' )
.insertAdjacentElement( 'beforeend', item );
} else {
const parentItem = document.querySelector(
`.prpl-suggested-task[data-task-id="${ parent }"]`
);
// If we could not find the parent item, try again after 500ms.
window.progressPlannerRenderAttempts =
window.progressPlannerRenderAttempts || 0;
if ( window.progressPlannerRenderAttempts > 500 ) {
return;
}
if ( ! parentItem ) {
setTimeout( () => {
progressPlannerInjectSuggestedTodoItem( details );
window.progressPlannerRenderAttempts++;
}, 10 );
return;
}

// If the child list does not exist, create it.
if ( ! parentItem.querySelector( '.prpl-suggested-task-children' ) ) {
const childListElement = document.createElement( 'ul' );
childListElement.classList.add( 'prpl-suggested-task-children' );
parentItem.appendChild( childListElement );
}
return;
}

// Inject the item into the child list.
parentItem
.querySelector( '.prpl-suggested-task-children' )
.insertAdjacentElement( 'beforeend', item );
// If we could not find the parent item, try again after 500ms.
window.progressPlannerRenderAttempts =
window.progressPlannerRenderAttempts || 0;
if ( window.progressPlannerRenderAttempts > 500 ) {
return;
}
const parentItem = document.querySelector(
`.prpl-suggested-task[data-task-id="${ parent }"]`
);
if ( ! parentItem ) {
setTimeout( () => {
progressPlannerInjectSuggestedTodoItem( details );
window.progressPlannerRenderAttempts++;
}, 10 );
return;
}

// If the child list does not exist, create it.
if ( ! parentItem.querySelector( '.prpl-suggested-task-children' ) ) {
const childListElement = document.createElement( 'ul' );
childListElement.classList.add( 'prpl-suggested-task-children' );
parentItem.appendChild( childListElement );
}

// Inject the item into the child list.
parentItem
.querySelector( '.prpl-suggested-task-children' )
.insertAdjacentElement( 'beforeend', item );
};

const prplTriggerConfetti = () => {
Expand Down
4 changes: 3 additions & 1 deletion classes/actions/class-content-scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

namespace Progress_Planner\Actions;

use Progress_Planner\Actions\Content;

/**
* Content scan class.
*/
class Content_Scan extends \Progress_Planner\Actions\Content {
class Content_Scan extends Content {

/**
* The option used to store the last scanned page.
Expand Down
4 changes: 3 additions & 1 deletion classes/actions/class-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Progress_Planner\Actions;

use Progress_Planner\Activities\Content as Activities_Content;

/**
* Content actions.
*/
Expand Down Expand Up @@ -190,7 +192,7 @@ public function delete_post( $post_id ) {
\progress_planner()->get_settings()->set( [ 'word_count', $post_id ], false );

// Add activity.
$activity = new \Progress_Planner\Activities\Content();
$activity = new Activities_Content();
$activity->category = 'content';
$activity->type = 'delete';
$activity->data_id = (string) $post_id;
Expand Down
4 changes: 3 additions & 1 deletion classes/actions/class-maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Progress_Planner\Actions;

use Progress_Planner\Activities\Maintenance as Activities_Maintenance;

/**
* Handle activities for updates.
*/
Expand Down Expand Up @@ -126,7 +128,7 @@ public function on_switch_theme() {
* @return void
*/
protected function create_maintenance_activity( $type ) {
$activity = new \Progress_Planner\Activities\Maintenance();
$activity = new Activities_Maintenance();
$activity->type = $type;
$activity->save();
}
Expand Down
4 changes: 3 additions & 1 deletion classes/activities/class-content-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Progress_Planner\Activities;

use Progress_Planner\Activities\Content as Activities_Content;

/**
* Helper methods for content activities.
*/
Expand Down Expand Up @@ -104,7 +106,7 @@ public function get_activity_from_post( $post ) {
$type = 'publish' === $post->post_status ? 'publish' : 'update';
$date = 'publish' === $post->post_status ? $post->post_date : $post->post_modified;

$activity = new \Progress_Planner\Activities\Content();
$activity = new Activities_Content();
$activity->category = 'content';
$activity->type = $type;
$activity->date = \progress_planner()->get_date()->get_datetime_from_mysql_date( $date );
Expand Down
4 changes: 3 additions & 1 deletion classes/activities/class-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

namespace Progress_Planner\Activities;

use Progress_Planner\Activity;

/**
* Handler for content activities.
*/
class Content extends \Progress_Planner\Activity {
class Content extends Activity {

/**
* Category of the activity.
Expand Down
4 changes: 3 additions & 1 deletion classes/activities/class-maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

namespace Progress_Planner\Activities;

use Progress_Planner\Activity;

/**
* Handle activities for maintenance activities.
*/
class Maintenance extends \Progress_Planner\Activity {
class Maintenance extends Activity {

/**
* Points configuration.
Expand Down
4 changes: 3 additions & 1 deletion classes/activities/class-suggested-task.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

namespace Progress_Planner\Activities;

use Progress_Planner\Activity;

/**
* Handler for suggested tasks activities.
*/
class Suggested_Task extends \Progress_Planner\Activity {
class Suggested_Task extends Activity {

/**
* Points configuration for suggested tasks activities.
Expand Down
4 changes: 3 additions & 1 deletion classes/activities/class-todo.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

namespace Progress_Planner\Activities;

use Progress_Planner\Activity;

/**
* Handler for todo activities.
*/
class Todo extends \Progress_Planner\Activity {
class Todo extends Activity {

/**
* Points configuration for todo activities.
Expand Down
4 changes: 3 additions & 1 deletion classes/admin/class-dashboard-widget-score.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

namespace Progress_Planner\Admin;

use Progress_Planner\Admin\Dashboard_Widget;

/**
* Class Dashboard_Widget_Score
*/
class Dashboard_Widget_Score extends \Progress_Planner\Admin\Dashboard_Widget {
class Dashboard_Widget_Score extends Dashboard_Widget {

/**
* The widget ID.
Expand Down
4 changes: 3 additions & 1 deletion classes/admin/class-dashboard-widget-todo.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

namespace Progress_Planner\Admin;

use Progress_Planner\Admin\Dashboard_Widget;

/**
* Class Dashboard_Widget_Todo
*/
class Dashboard_Widget_Todo extends \Progress_Planner\Admin\Dashboard_Widget {
class Dashboard_Widget_Todo extends Dashboard_Widget {

/**
* The widget ID.
Expand Down
8 changes: 5 additions & 3 deletions classes/admin/class-page-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Progress_Planner\Admin;

use Progress_Planner\Page_Types;

/**
* Admin class.
*/
Expand Down Expand Up @@ -77,7 +79,7 @@ public function get_settings() {
];
}

return apply_filters( 'progress_planner_settings', $settings );
return $settings;
}

/**
Expand Down Expand Up @@ -128,13 +130,13 @@ public function store_settings_form_options() {
}

// Get the term-ID for the type.
$term = \get_term_by( 'slug', $type, \Progress_Planner\Page_Types::TAXONOMY_NAME );
$term = \get_term_by( 'slug', $type, Page_Types::TAXONOMY_NAME );
if ( ! $term instanceof \WP_Term ) {
continue;
}

// Remove the assigned terms from the `progress_planner_page_types` taxonomy.
\wp_remove_object_terms( $post->ID, $term->term_id, \Progress_Planner\Page_Types::TAXONOMY_NAME );
\wp_remove_object_terms( $post->ID, $term->term_id, Page_Types::TAXONOMY_NAME );
}

// Skip if the ID is not set.
Expand Down
7 changes: 5 additions & 2 deletions classes/badges/class-badge-maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Progress_Planner\Badges;

use Progress_Planner\Goals\Goal_Recurring;
use Progress_Planner\Goals\Goal;

/**
* Badge class.
*/
Expand All @@ -18,10 +21,10 @@ abstract class Badge_Maintenance extends Badge {
* @return \Progress_Planner\Goals\Goal_Recurring
*/
public function get_goal() {
return \Progress_Planner\Goals\Goal_Recurring::get_instance(
return Goal_Recurring::get_instance(
'weekly_activity',
[
'class_name' => \Progress_Planner\Goals\Goal::class,
'class_name' => Goal::class,
'id' => 'weekly_activity',
'title' => \esc_html__( 'Weekly activity', 'progress-planner' ),
'description' => \esc_html__( 'Streak: The number of weeks this goal has been accomplished consistently.', 'progress-planner' ),
Expand Down
17 changes: 6 additions & 11 deletions classes/badges/class-monthly.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ public static function init_badges() {
$start_date = $activation_date->modify( 'first day of this month' );

// Year when plugin was released.
if ( 2024 === (int) $start_date->format( 'Y' ) ) {
$end_date = new \DateTime( 'last day of December next year' );
} else {
$end_date = new \DateTime( 'last day of December this year' );
}
$end_date = ( 2024 === (int) $start_date->format( 'Y' ) )
? new \DateTime( 'last day of December next year' )
: new \DateTime( 'last day of December this year' );

$dates = iterator_to_array( new \DatePeriod( $start_date, new \DateInterval( 'P1M' ), $end_date ), false );

Expand Down Expand Up @@ -209,17 +207,14 @@ public function progress_callback() {
$points += $activity->get_points( $activity->date );
}

if ( $points > self::TARGET_POINTS ) {
$return_progress = [
$return_progress = ( $points > self::TARGET_POINTS )
? [
'progress' => 100,
'remaining' => 0,
];
} else {
$return_progress = [
] : [
'progress' => (int) max( 0, min( 100, floor( 100 * $points / self::TARGET_POINTS ) ) ),
'remaining' => self::TARGET_POINTS - $points,
];
}

$this->save_progress( $return_progress );

Expand Down
4 changes: 3 additions & 1 deletion classes/badges/content/class-awesome-author.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

namespace Progress_Planner\Badges\Content;

use Progress_Planner\Badges\Badge_Content;

/**
* Badge class.
*/
final class Awesome_Author extends \Progress_Planner\Badges\Badge_Content {
final class Awesome_Author extends Badge_Content {

/**
* The badge ID.
Expand Down
Loading

0 comments on commit 554d635

Please sign in to comment.