-
Notifications
You must be signed in to change notification settings - Fork 368
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/usage tracking improvements #2593
Conversation
@@ -11,22 +11,34 @@ | |||
?> | |||
<h3><?php esc_html_e( 'Welcome to the Setup Wizard!', 'wp-job-manager' ); ?></h3> | |||
|
|||
<script type="text/javascript"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why we don't do this in PHP directly. Changed that in 00ba0f0
@mikeyarce let me know if there is something that I'm missing here.
includes/class-wp-job-manager.php
Outdated
* | ||
* @since $$next-version$$ | ||
*/ | ||
public function set_activation_time() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that creating a function that has a single statement makes code a bit harder to read, especially when this function is called only once. You can argue that sometimes when a single statement is very complicated, it makes it easier to understand it if you give it a name with a function but I don't think this is the case here.
includes/class-wp-job-manager.php
Outdated
* @since $$next-version$$ | ||
*/ | ||
public function set_activation_time() { | ||
set_transient( 'job_manager_activation_time', time() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Transients should be thought of as a cache that can be deleted any time. In our case this won't be a big issue but I think that having an option for that will be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are on Support Rotation this week Mikey, I'll pick up the changes for this PR. I just left the comments for documentation purposes.
*/ | ||
function delay_tracking_notice() { | ||
$activation_time = get_transient( 'job_manager_activation_time' ); | ||
if ( $activation_time && ( time() - $activation_time ) > 604800 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WP defines a few useful constants for these:
define( 'MINUTE_IN_SECONDS', 60 );
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
define( 'MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS );
define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS );
Hey @fjorgemota since the rest of the team is in support rotation, can you take a look at these changes? The testing instructions should be updated as:
|
94c4ef3
to
3ac64ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking generally good. I'll test it further tomorrow.
From what I'm seeing, when I deactivate and then activate, the notice looks to be appearing even when the option job_manager_display_usage_tracking_once
is in the future (with value 1696893421
), after removing the option wp_job_manager_version
. I'm not sure if I'm doing something wrong, but I'll test more tomorrow.
4001a4b
to
bdc97ca
Compare
Well spotted! The logic was flawed, fixed in cc81563 |
8cde992
to
cc81563
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! Thanks a lot for making these changes.
I reviewed them all and now the feature works properly. Also tried updating the option job_manager_display_usage_tracking_once
to a value generated by strtotime('+1 minute');
and I could confirm that now the feature works beautifully.
Also, the linting changes look great.
Thanks a lot! Approved!
(I still left two very minor comments with suggestions, but I believe you can consider the PR as approved after the changes)
Co-authored-by: Fernando Jorge Mota <fjorgemota@users.noreply.github.com>
Co-authored-by: Fernando Jorge Mota <fjorgemota@users.noreply.github.com>
3667af2
to
55b537b
Compare
There are some issues unrelated to this PR. I'll go ahead with merging this one and fix them as part of a separate PR |
Fixes #2580
Changes proposed in this Pull Request
target="_blank"
attributes to some links that did not have them.Testing instructions
/wp-admin/index.php?page=job-manager-setup
Save and Skip setup
and make sure the option is saved properlydelay_tracking_notice
to display the notice.WP_Job_manager::updater()
function so that the condition is true and so that the code runs