Skip to content

Commit 1a6ec1f

Browse files
committed
use our constant & remove unused enqueue
1 parent 512388d commit 1a6ec1f

3 files changed

Lines changed: 10 additions & 22 deletions

File tree

assets/js/widgets/suggested-tasks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const prplSuggestedTasksWidget = {
4545
} );
4646

4747
// We trigger celebration only on Progress Planner dashboard page.
48-
if ( 'dashboard' !== window.pagenow ) {
48+
if ( ! prplSuggestedTask.delayCelebration ) {
4949
// Inject pending celebration tasks.
5050
celebrationPromises.push(
5151
prplSuggestedTask

classes/admin/class-enqueue.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ public function localize_script( $handle, $localize_data = [] ) {
219219
if ( isset( $max_items_per_category['user'] ) ) {
220220
$max_items_per_category['user'] = 100;
221221
}
222+
223+
// Celebrate only on the Progress Planner Dashboard page.
224+
$delay_celebration = true;
225+
if ( \progress_planner()->is_on_progress_planner_dashboard_page() ) {
226+
// should_show_upgrade_popover() also checks if we're on the Progress Planner Dashboard page - but let's be explicit since that method might change in the future.
227+
$delay_celebration = \progress_planner()->get_plugin_upgrade_tasks()->should_show_upgrade_popover();
228+
}
229+
222230
$localize_data = [
223231
'name' => 'prplSuggestedTask',
224232
'data' => [
@@ -228,6 +236,7 @@ public function localize_script( $handle, $localize_data = [] ) {
228236
'snoozeIcon' => constant( 'PROGRESS_PLANNER_URL' ) . '/assets/images/icon_snooze.svg',
229237
],
230238
'maxItemsPerCategory' => apply_filters( 'progress_planner_suggested_tasks_max_items_per_category', $max_items_per_category ),
239+
'delayCelebration' => $delay_celebration,
231240
],
232241
];
233242
break;

classes/admin/widgets/class-suggested-tasks.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,6 @@ public function get_score() {
4949
* @return void
5050
*/
5151
public function enqueue_scripts() {
52-
// Celebrate only on the Progress Planner Dashboard page.
53-
$delay_celebration = false;
54-
if ( \progress_planner()->is_on_progress_planner_dashboard_page() ) {
55-
// should_show_upgrade_popover() also checks if we're on the Progress Planner Dashboard page - but let's be explicit since that method might change in the future.
56-
$delay_celebration = \progress_planner()->get_plugin_upgrade_tasks()->should_show_upgrade_popover();
57-
}
58-
59-
// Enqueue the script.
60-
\progress_planner()->get_admin__enqueue()->enqueue_script(
61-
'widgets/suggested-tasks',
62-
[
63-
'name' => 'prplSuggestedTasks',
64-
'data' => [
65-
'ajaxUrl' => \admin_url( 'admin-ajax.php' ),
66-
'nonce' => \wp_create_nonce( 'progress_planner' ),
67-
'tasks' => [], // This is set in the JS file.
68-
'delayCelebration' => $delay_celebration,
69-
],
70-
]
71-
);
72-
7352
// Enqueue the badge scroller script.
7453
\progress_planner()->get_admin__enqueue()->enqueue_script(
7554
'widgets/suggested-tasks-badge-scroller',

0 commit comments

Comments
 (0)