Skip to content

Commit ef8a14e

Browse files
authored
Merge pull request #638 from ProgressPlanner/ari/code-review
code review tweaks
2 parents 15f9fb3 + 4842fd3 commit ef8a14e

12 files changed

Lines changed: 52 additions & 107 deletions

assets/css/admin.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,4 +558,3 @@ button.prpl-info-icon {
558558
transform: rotate(360deg);
559559
}
560560
}
561-

views/admin-page-header.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
exit;
1111
}
1212

13-
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
14-
$progress_planner_active_range = isset( $_GET['range'] ) ? \sanitize_text_field( \wp_unslash( $_GET['range'] ) ) : '-6 months';
15-
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
16-
$progress_planner_active_frequency = isset( $_GET['frequency'] ) ? \sanitize_text_field( \wp_unslash( $_GET['frequency'] ) ) : 'monthly';
17-
1813
\do_action( 'progress_planner_admin_page_header_before' );
1914
?>
2015
<div class="prpl-header">
@@ -55,7 +50,7 @@
5550
\printf(
5651
'<option value="%1$s" %2$s>%3$s</option>',
5752
\esc_attr( $progress_planner_range ),
58-
\selected( $progress_planner_active_range, $progress_planner_range, false ),
53+
\selected( isset( $_GET['range'] ) ? \sanitize_text_field( \wp_unslash( $_GET['range'] ) ) : '-6 months', $progress_planner_range, false ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
5954
\esc_html( $progress_planner_label )
6055
);
6156
}
@@ -73,7 +68,7 @@
7368
\printf(
7469
'<option value="%1$s" %2$s>%3$s</option>',
7570
\esc_attr( $progress_planner_frequency ),
76-
\selected( $progress_planner_active_frequency, $progress_planner_frequency, false ),
71+
\selected( isset( $_GET['frequency'] ) ? \sanitize_text_field( \wp_unslash( $_GET['frequency'] ) ) : 'monthly', $progress_planner_frequency, false ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
7772
\esc_html( $progress_planner_label )
7873
);
7974
}

views/admin-page.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
}
1212

1313
$prpl_privacy_policy_accepted = \progress_planner()->is_privacy_policy_accepted();
14-
$prpl_wrapper_class = '';
1514

1615
if ( 0 !== (int) \progress_planner()->get_ui__branding()->get_branding_id() ) {
1716
$prpl_license_key = \progress_planner()->get_utils__onboard()->make_remote_onboarding_request();
@@ -20,13 +19,9 @@
2019
$prpl_privacy_policy_accepted = true;
2120
}
2221
}
23-
24-
if ( ! $prpl_privacy_policy_accepted ) {
25-
$prpl_wrapper_class = 'prpl-pp-not-accepted';
26-
}
2722
?>
2823

29-
<div class="wrap prpl-wrap <?php echo \esc_attr( $prpl_wrapper_class ); ?>">
24+
<div class="wrap prpl-wrap <?php echo \esc_attr( $prpl_privacy_policy_accepted ? '' : 'prpl-pp-not-accepted' ); ?>">
3025
<?php if ( true === $prpl_privacy_policy_accepted ) : ?>
3126
<h1 class="screen-reader-text"><?php \esc_html_e( 'Progress Planner', 'progress-planner' ); ?></h1>
3227
<?php \progress_planner()->the_view( 'admin-page-header.php' ); ?>

views/page-widgets/content-activity.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ function ( $activity ) use ( $prpl_tracked_post_types ) {
9797
);
9898
?>
9999
</h2>
100-
<p>
101-
<?php \esc_html_e( 'Here are the updates you made to your content last week. Whether you published something new, updated an existing post, or removed outdated content, it all helps you stay on top of your site!', 'progress-planner' ); ?>
102-
</p>
100+
<p><?php \esc_html_e( 'Here are the updates you made to your content last week. Whether you published something new, updated an existing post, or removed outdated content, it all helps you stay on top of your site!', 'progress-planner' ); ?></p>
103101

104102
<prpl-big-counter
105103
number="<?php echo \esc_html( \number_format_i18n( (int) $prpl_activities_count['all'] ) ); ?>"

views/page-widgets/latest-badge.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
<p><?php \esc_html_e( 'You haven\'t unlocked any badges yet. Hang on, you\'ll get there!', 'progress-planner' ); ?></p>
2626
<?php else : ?>
2727
<p>
28-
<?php if ( \str_starts_with( $prpl_latest_badge->get_id(), 'monthly-' ) ) : ?>
29-
<?php \esc_html_e( 'Wooohoooo! Congratulations! You have earned a new badge.', 'progress-planner' ); ?>
30-
<?php else : ?>
31-
<?php
28+
<?php
29+
if ( \str_starts_with( $prpl_latest_badge->get_id(), 'monthly-' ) ) {
30+
\esc_html_e( 'Wooohoooo! Congratulations! You have earned a new badge.', 'progress-planner' );
31+
} else {
3232
\printf(
3333
/* translators: %s: The badge name. */
3434
\esc_html__( 'Wooohoooo! Congratulations! You have earned a new badge. You are now a %s.', 'progress-planner' ),
3535
'<strong>' . \esc_html( $prpl_latest_badge->get_name() ) . '</strong>'
3636
);
37-
?>
38-
<?php endif; ?>
37+
}
38+
?>
3939
</p>
4040
<img
4141
src="<?php echo \esc_url( \progress_planner()->get_admin__widgets__latest_badge()->endpoint . $prpl_latest_badge->get_id() ); ?>"

views/page-widgets/monthly-badges.php

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,34 +54,15 @@
5454
<hr>
5555
<?php endif; ?>
5656

57-
58-
5957
<div class="prpl-widget-content">
60-
<?php if ( 2024 === (int) \gmdate( 'Y' ) ) : ?>
61-
<?php
62-
\progress_planner()->the_view(
63-
'page-widgets/parts/monthly-badges-2024.php',
64-
[
65-
'title_tag' => 'h2',
66-
]
67-
);
68-
?>
69-
<?php else : ?>
70-
71-
<?php
72-
\progress_planner()->the_view(
73-
'page-widgets/parts/monthly-badges.php',
74-
[
75-
'title_year' => 2025,
76-
]
77-
);
78-
?>
79-
<?php endif; ?>
8058
<?php
81-
\progress_planner()->get_ui__popover()->the_popover( 'monthly-badges' )->render_button(
82-
'',
83-
\esc_html__( 'Show all badges', 'progress-planner' )
84-
);
59+
if ( 2024 === (int) \gmdate( 'Y' ) ) {
60+
\progress_planner()->the_view( 'page-widgets/parts/monthly-badges-2024.php', [ 'title_tag' => 'h2' ] );
61+
} else {
62+
\progress_planner()->the_view( 'page-widgets/parts/monthly-badges.php', [ 'title_year' => 2025 ] );
63+
}
64+
65+
\progress_planner()->get_ui__popover()->the_popover( 'monthly-badges' )->render_button( '', \esc_html__( 'Show all badges', 'progress-planner' ) );
8566
\progress_planner()->get_ui__popover()->the_popover( 'monthly-badges' )->render();
8667
?>
8768
</div>

views/page-widgets/suggested-tasks.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@
3838
<p class="prpl-suggested-tasks-loading">
3939
<?php \esc_html_e( 'Loading tasks...', 'progress-planner' ); ?>
4040
</p>
41-
<?php
42-
// Check if the request URI contains the parameter 'prpl_show_all_recommendations'.
43-
$prpl_request_uri = isset( $_SERVER['REQUEST_URI'] ) ? \sanitize_text_field( \wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
44-
?>
41+
<?php // Check if the request URI contains the parameter 'prpl_show_all_recommendations'. ?>
42+
<?php $prpl_request_uri = isset( $_SERVER['REQUEST_URI'] ) ? \sanitize_text_field( \wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; ?>
4543
<p class="prpl-show-all-tasks">
4644
<?php if ( false === strpos( $prpl_request_uri, 'prpl_show_all_recommendations' ) ) : ?>
4745
<a href="<?php echo \esc_url( \add_query_arg( 'prpl_show_all_recommendations', '', \admin_url( 'admin.php?page=progress-planner&prpl_show_all_recommendations' ) ) ); ?>">

views/popovers/email-sending.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<div class="prpl-column prpl-column-content">
2222
<h2 class="prpl-interactive-task-title"><?php \esc_html_e( 'Test if your site can send emails', 'progress-planner' ); ?></h2>
2323
<p class="prpl-interactive-task-description"><?php \esc_html_e( 'Your WordPress site sometimes needs to send emails. For example, to reset a password, send a comment notification, or warn you when something breaks. Contact forms also use email.', 'progress-planner' ); ?></p>
24-
<p class="prpl-interactive-task-description"><?php \esc_html_e( 'It’s important to check if these emails are actually sent. Enter your email address on the right to get a test email.', 'progress-planner' ); ?></p>
24+
<p class="prpl-interactive-task-description"><?php \esc_html_e( 'It is important to check if these emails are actually sent. Enter your email address on the right to get a test email.', 'progress-planner' ); ?></p>
2525
</div>
2626
<div class="prpl-column">
2727
<p><?php \esc_html_e( 'Where should we send the test email?', 'progress-planner' ); ?></p>
@@ -38,10 +38,8 @@
3838

3939
<div class="prpl-steps-nav-wrapper">
4040
<button class="prpl-button" data-action="showResults" type="submit">
41-
<?php
42-
/* translators: %s is a forward arrow icon. */
43-
\printf( \esc_html__( 'Next step %s', 'progress-planner' ), '<span class="dashicons dashicons-arrow-right-alt2"></span>' );
44-
?>
41+
<?php /* translators: %s is a forward arrow icon. */ ?>
42+
<?php \printf( \esc_html__( 'Next step %s', 'progress-planner' ), '<span class="dashicons dashicons-arrow-right-alt2"></span>' ); ?>
4543
</button>
4644
</div>
4745
</form>
@@ -72,7 +70,7 @@
7270
<span class="prpl-note-text" data-email-message="
7371
<?php
7472
/* translators: %s is the error message. */
75-
\printf( \esc_attr__( 'The test email didn’t work. The error message was: [ERROR_MESSAGE]', 'progress-planner' ), \esc_attr( $prpl_email_error ) );
73+
\printf( \esc_attr__( 'The test email did not work. The error message was: [ERROR_MESSAGE]', 'progress-planner' ), \esc_attr( $prpl_email_error ) );
7674
?>
7775
">
7876
</span>
@@ -82,7 +80,7 @@
8280
<?php
8381
\printf(
8482
/* translators: %s is a link to the troubleshooting guide. */
85-
\esc_html__( 'There are a few common reasons why your email might not be sending. Check the %s to find out what’s causing the issue and how to fix it.', 'progress-planner' ),
83+
\esc_html__( 'There are a few common reasons why your email might not be sending. Check the %s to find out what is causing the issue and how to fix it.', 'progress-planner' ),
8684
'<a href="' . \esc_url( $prpl_troubleshooting_guide_url ) . '" target="_blank">' . \esc_html__( 'troubleshooting guide', 'progress-planner' ) . '</a>'
8785
);
8886
?>
@@ -184,7 +182,8 @@
184182
<p class="prpl-interactive-task-description">
185183
<?php \esc_html_e( 'We\'re sorry to hear you did not receive our confirmation email yet. On some websites, it make take up to a few hours to send email. That\'s why we strongly advise you to check back in a few hours from now.', 'progress-planner' ); ?>
186184
</p>
187-
<p class="prpl-interactive-task-description"><?php \esc_html_e( 'If you already waited a couple of hours and you still didn\'t get our email, your email might not be working well.', 'progress-planner' ); ?>
185+
<p class="prpl-interactive-task-description">
186+
<?php \esc_html_e( 'If you already waited a couple of hours and you still didn\'t get our email, your email might not be working well.', 'progress-planner' ); ?>
188187
</p>
189188
</div>
190189

views/popovers/monthly-badges.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,13 @@
5252
<?php $prpl_group_badges = \progress_planner()->get_badges()->get_badges( $prpl_badge_group ); ?>
5353
<div class="progress-wrapper badge-group-<?php echo \esc_attr( $prpl_badge_group ); ?>">
5454
<?php foreach ( $prpl_group_badges as $prpl_badge ) : ?>
55-
<?php
56-
$prpl_badge_progress = $prpl_badge->get_progress();
57-
$prpl_badge_completed = 100 === (int) $prpl_badge_progress['progress'];
58-
?>
55+
<?php $prpl_badge_progress = $prpl_badge->get_progress(); ?>
5956
<span
6057
class="prpl-badge"
6158
data-value="<?php echo \esc_attr( $prpl_badge_progress['progress'] ); ?>"
6259
>
6360
<prpl-badge
64-
complete="<?php echo $prpl_badge_completed ? 'true' : 'false'; ?>"
61+
complete="<?php echo 100 === (int) $prpl_badge_progress['progress'] ? 'true' : 'false'; ?>"
6562
badge-id="<?php echo \esc_attr( $prpl_badge->get_id() ); ?>"
6663
badge-name="<?php echo \esc_attr( $prpl_badge->get_name() ); ?>"
6764
branding-id="<?php echo (int) \progress_planner()->get_ui__branding()->get_branding_id(); ?>"

views/popovers/subscribe-form.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
<form id="prpl-settings-license-form">
1919
<p>
20-
<?php
21-
\printf(
22-
/* translators: %s: progressplanner.com link */
23-
\esc_html__( 'We can send you weekly emails with your own to-do’s, your activity stats and nudges to keep you working on your site. To do this, we’ll create an account for you on %s.', 'progress-planner' ),
24-
'<a href="' . \esc_url( \progress_planner()->get_ui__branding()->get_url( 'https://prpl.fyi/home' ) ) . '" target="_blank">progressplanner.com</a>'
25-
)
26-
?>
20+
<?php
21+
\printf(
22+
/* translators: %s: progressplanner.com link */
23+
\esc_html__( 'We can send you weekly emails with your own to-dos, your activity stats and nudges to keep you working on your site. To do this, we’ll create an account for you on %s.', 'progress-planner' ),
24+
'<a href="' . \esc_url( \progress_planner()->get_ui__branding()->get_url( 'https://prpl.fyi/home' ) ) . '" target="_blank">progressplanner.com</a>'
25+
)
26+
?>
2727
</p>
2828
<div class="prpl-form-fields">
2929
<label>

0 commit comments

Comments
 (0)