From c752c35cad5220d601d750ba7dff5f255fcdc8a3 Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Fri, 20 Dec 2024 16:29:08 +0100 Subject: [PATCH 1/7] implement design changes --- assets/css/dashboard-widgets/score.css | 7 ++++--- assets/js/web-components/prpl-gauge.js | 14 ++++++++++++-- assets/js/widgets/suggested-tasks.js | 7 ++++--- classes/widgets/class-suggested-tasks.php | 9 ++++++--- views/dashboard-widgets/score.php | 12 ++++++------ 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/assets/css/dashboard-widgets/score.css b/assets/css/dashboard-widgets/score.css index 97d43f0f8..4d4cfbf5c 100644 --- a/assets/css/dashboard-widgets/score.css +++ b/assets/css/dashboard-widgets/score.css @@ -1,6 +1,7 @@ #progress_planner_dashboard_widget_score { .prpl-dashboard-widget { + padding-top: 5px; /* Total 16px top spacing */ display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); grid-gap: calc(var(--prpl-gap) / 2); @@ -36,12 +37,12 @@ } .prpl-dashboard-widget-footer { - margin-top: 1em; - padding-top: 1em; + margin-top: 1rem; + padding-top: 1rem; border-top: 1px solid #c3c4c7; /* same color as the one WP-Core uses */ font-size: var(--prpl-font-size-base); display: flex; - gap: 1em; + gap: 0.5rem; align-items: center; } } diff --git a/assets/js/web-components/prpl-gauge.js b/assets/js/web-components/prpl-gauge.js index 0ccc0a12e..c82dec531 100644 --- a/assets/js/web-components/prpl-gauge.js +++ b/assets/js/web-components/prpl-gauge.js @@ -16,6 +16,9 @@ customElements.define( start: '270deg', cutout: '57%', contentFontSize: 'var(--prpl-font-size-6xl)', + contentPadding: + 'var(--prpl-padding) var(--prpl-padding) calc(var(--prpl-padding) * 2) var(--prpl-padding)', + marginBottom: 'var(--prpl-padding)', }, content = '' ) { @@ -41,11 +44,18 @@ customElements.define( props.cutout = this.getAttribute( 'cutout' ) || props.cutout; props.contentFontSize = this.getAttribute( 'contentFontSize' ) || props.contentFontSize; + props.contentPadding = + this.getAttribute( 'contentPadding' ) || props.contentPadding; + props.marginBottom = + this.getAttribute( 'marginBottom' ) || props.marginBottom; this.innerHTML = ` -
+ }; border-radius:var(--prpl-border-radius-big); aspect-ratio: 2 / 1; overflow: hidden; position: relative; margin-bottom: ${ + props.marginBottom + };">
- + @@ -22,7 +22,7 @@
- + get_widgets__activity_scores()->get_score() ); ?> @@ -31,7 +31,7 @@
-
+

@@ -39,9 +39,9 @@ From 25f00ace469d1af9a7ba5a6ef710fadb89e55821 Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Fri, 20 Dec 2024 16:49:46 +0100 Subject: [PATCH 2/7] Add Pro logo version --- assets/images/logo_progress_planner_pro.svg | 1 + views/admin-page-header.php | 8 +++++++- views/admin-page-settings.php | 8 +++++++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 assets/images/logo_progress_planner_pro.svg diff --git a/assets/images/logo_progress_planner_pro.svg b/assets/images/logo_progress_planner_pro.svg new file mode 100644 index 000000000..1532dfc31 --- /dev/null +++ b/assets/images/logo_progress_planner_pro.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/admin-page-header.php b/views/admin-page-header.php index 0d0d43fb6..493fc10b0 100644 --- a/views/admin-page-header.php +++ b/views/admin-page-header.php @@ -19,7 +19,13 @@ ?>
diff --git a/views/admin-page-settings.php b/views/admin-page-settings.php index 9a5b16a83..ebf4e299d 100644 --- a/views/admin-page-settings.php +++ b/views/admin-page-settings.php @@ -14,7 +14,13 @@

From 266d185a7e296e0d351b3326a37032f75fed34c6 Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Fri, 27 Dec 2024 08:36:50 +0100 Subject: [PATCH 3/7] merge methods & remove post_updated hook --- classes/actions/class-content.php | 82 +++++++++++-------------------- 1 file changed, 28 insertions(+), 54 deletions(-) diff --git a/classes/actions/class-content.php b/classes/actions/class-content.php index 4291c1e8c..a1f8c120e 100644 --- a/classes/actions/class-content.php +++ b/classes/actions/class-content.php @@ -27,11 +27,9 @@ public function __construct() { * @return void */ public function register_hooks() { - // Add activity when a post is updated. - \add_action( 'post_updated', [ $this, 'post_updated' ], 10, 2 ); - // Add activity when a post is added. - \add_action( 'wp_insert_post', [ $this, 'insert_post' ], 10, 2 ); + // Add activity when a post is added or updated. + \add_action( 'wp_insert_post', [ $this, 'insert_post' ], 10, 3 ); \add_action( 'transition_post_status', [ $this, 'transition_post_status' ], 10, 3 ); // Add activity when a post is trashed or deleted. @@ -40,84 +38,60 @@ public function register_hooks() { } /** - * Post updated. + * Insert a post. * - * Runs on post_updated hook. + * Runs on wp_insert_post hook. * * @param int $post_id The post ID. * @param \WP_Post $post The post object. - * + * @param bool $update Whether this is an update. * @return void */ - public function post_updated( $post_id, $post ) { + public function insert_post( $post_id, $post, $update ) { // Bail if we should skip saving. if ( $this->should_skip_saving( $post ) ) { return; } - // Reset the words count. - \progress_planner()->get_settings()->set( [ 'word_count', $post_id ], false ); + // Set the type of activity. + $type = $update ? 'update' : 'publish'; - if ( 'publish' !== $post->post_status ) { - return; + // Reset the words count if it's an update. + if ( 'update' === $type ) { + \progress_planner()->get_settings()->set( [ 'word_count', $post_id ], false ); } - // Check if there is an update activity for this post, on this date. - $existing = \progress_planner()->get_query()->query_activities( - [ - 'category' => 'content', - 'type' => 'update', - 'data_id' => (string) $post_id, - 'start_date' => \progress_planner()->get_date()->get_datetime_from_mysql_date( $post->post_modified )->modify( '-12 hours' ), - 'end_date' => \progress_planner()->get_date()->get_datetime_from_mysql_date( $post->post_modified )->modify( '+12 hours' ), - ], - 'RAW' - ); - - // If there is an update activity for this post, on this date, bail. - if ( ! empty( $existing ) ) { + // Bail if the post is not published. + if ( 'publish' !== $post->post_status ) { return; } - $this->add_post_activity( $post, 'update' ); - } - - /** - * Insert a post. - * - * Runs on wp_insert_post hook. - * - * @param int $post_id The post ID. - * @param \WP_Post $post The post object. - * @return void - */ - public function insert_post( $post_id, $post ) { - // Bail if we should skip saving. - if ( $this->should_skip_saving( $post ) ) { - return; - } + // Query arguments. + $query_args = [ + 'category' => 'content', + 'type' => $type, + 'data_id' => (string) $post_id, + ]; - if ( 'publish' !== $post->post_status ) { - return; + // If it's an update add the start and end date. We don't want to add multiple update activities for the same post on the same day. + if ( 'update' === $type ) { + $query_args['start_date'] = \progress_planner()->get_date()->get_datetime_from_mysql_date( $post->post_modified )->modify( '-12 hours' ); + $query_args['end_date'] = \progress_planner()->get_date()->get_datetime_from_mysql_date( $post->post_modified )->modify( '+12 hours' ); } - // Check if there is a publish activity for this post. + // Check if there is an activity for this post. $existing = \progress_planner()->get_query()->query_activities( - [ - 'category' => 'content', - 'type' => 'publish', - 'data_id' => (string) $post_id, - ], + $query_args, 'RAW' ); - // If there is a publish activity for this post, bail. + // If there is an activity for this post, bail. if ( ! empty( $existing ) ) { return; } - // Add a publish activity. - $this->add_post_activity( $post, 'publish' ); + // Finally add an activity. + $this->add_post_activity( $post, $type ); } /** From 78f0fc8789634070c5bc92e15fcca1b013c62e66 Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Fri, 27 Dec 2024 12:36:51 +0100 Subject: [PATCH 4/7] fix repeated draft activities --- classes/actions/class-content.php | 60 ++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/classes/actions/class-content.php b/classes/actions/class-content.php index a1f8c120e..3f299e351 100644 --- a/classes/actions/class-content.php +++ b/classes/actions/class-content.php @@ -66,27 +66,8 @@ public function insert_post( $post_id, $post, $update ) { return; } - // Query arguments. - $query_args = [ - 'category' => 'content', - 'type' => $type, - 'data_id' => (string) $post_id, - ]; - - // If it's an update add the start and end date. We don't want to add multiple update activities for the same post on the same day. - if ( 'update' === $type ) { - $query_args['start_date'] = \progress_planner()->get_date()->get_datetime_from_mysql_date( $post->post_modified )->modify( '-12 hours' ); - $query_args['end_date'] = \progress_planner()->get_date()->get_datetime_from_mysql_date( $post->post_modified )->modify( '+12 hours' ); - } - - // Check if there is an activity for this post. - $existing = \progress_planner()->get_query()->query_activities( - $query_args, - 'RAW' - ); - - // If there is an activity for this post, bail. - if ( ! empty( $existing ) ) { + // Bail if there is a recent activity for this post. + if ( $this->is_there_recent_activity( $post, $type ) ) { return; } @@ -112,6 +93,11 @@ public function transition_post_status( $new_status, $old_status, $post ) { return; } + // Bail if there is a recent activity for this post. + if ( $this->is_there_recent_activity( $post, $new_status ) ) { + return; + } + // Add activity. $this->add_post_activity( $post, $new_status === 'publish' ? 'publish' : 'update' ); } @@ -210,6 +196,38 @@ private function should_skip_saving( $post ) { return false; } + /** + * Check if there is a recent activity for this post. + * + * @param \WP_Post $post The post object. + * @param string $type The type of activity (ie publish, update, trash, delete etc). + * + * @return bool + */ + private function is_there_recent_activity( $post, $type ) { + // Query arguments. + $query_args = [ + 'category' => 'content', + 'type' => $type, + 'data_id' => (string) $post->ID, + ]; + + // If it's an update add the start and end date. We don't want to add multiple update activities for the same post on the same day. + if ( 'update' === $type ) { + $query_args['start_date'] = \progress_planner()->get_date()->get_datetime_from_mysql_date( $post->post_modified )->modify( '-12 hours' ); + $query_args['end_date'] = \progress_planner()->get_date()->get_datetime_from_mysql_date( $post->post_modified )->modify( '+12 hours' ); + } + + // Check if there is an activity for this post. + $existing = \progress_planner()->get_query()->query_activities( + $query_args, + 'RAW' + ); + + // If there is an activity for this post, bail. + return ! empty( $existing ) ? true : false; + } + /** * Add an update activity. * From aa393fff9011b14dbde7458eb6919e65a7d68b3d Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Fri, 3 Jan 2025 07:27:21 +0100 Subject: [PATCH 5/7] set scrollable area height when remote images are loaded --- assets/js/widgets/suggested-tasks.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/assets/js/widgets/suggested-tasks.js b/assets/js/widgets/suggested-tasks.js index 98a8cc15e..1f7d85cf5 100644 --- a/assets/js/widgets/suggested-tasks.js +++ b/assets/js/widgets/suggested-tasks.js @@ -299,8 +299,18 @@ class BadgeScroller { init() { this.addEventListeners(); - // On page load. - this.setWrapperHeight(); + // On page load, when all images are loaded. + const images = [ ...this.element.querySelectorAll( 'img' ) ]; + if ( images.length ) { + Promise.all( + images.map( + ( im ) => + new Promise( ( resolve ) => ( im.onload = resolve ) ) + ) + ).then( () => { + this.setWrapperHeight(); + } ); + } // When popover is opened. document From e7770679c2b48253962cb50a16cd569351685375 Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Fri, 3 Jan 2025 07:27:43 +0100 Subject: [PATCH 6/7] fix new year badges --- classes/badges/class-monthly.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/badges/class-monthly.php b/classes/badges/class-monthly.php index 85092b6ef..06a0af062 100644 --- a/classes/badges/class-monthly.php +++ b/classes/badges/class-monthly.php @@ -57,7 +57,7 @@ public static function init_badges() { $start_date = $activation_date->modify( 'first day of this month' ); // Year when plugin was released. - $end_date = ( 2024 === (int) $start_date->format( 'Y' ) ) + $end_date = ( 2024 === (int) $start_date->format( 'Y' ) && 2024 === (int) \gmdate( 'Y' ) ) ? new \DateTime( 'last day of December next year' ) : new \DateTime( 'last day of December this year' ); From 1ab1fc13f0f7fa4d21e2d2258f47035cf3a3ef67 Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Fri, 3 Jan 2025 07:45:51 +0100 Subject: [PATCH 7/7] update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 932259d51..1aecceb95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,9 @@ Fixed: * Duplicate weekly suggested tasks. -* Fixed the REST API endpoint for getting stats. +* The REST API endpoint for getting stats. +* Scrollable monthly badges widget height on page load. +* 2026 monthly badges showing up = 1.0.1 =