-
Notifications
You must be signed in to change notification settings - Fork 381
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
Replace the 'Settings saved' notice, only on changing the Template Mode #1443
Conversation
…ething The copy can still change, but this now has Leo's copy for all 3 template modes.
👍
I don't think this should be the case necessarily. If it only shows when changing the template mode, then in reality it won't show very much.
This surfaces the discussion we had awhile ago about showing the validation status alongside each of the supportable templates. When visiting the AMP settings screen, I think we need to make sure that there are some invalid URLs captured for us to show. This could be done server-side when switching the mode, or when visiting this settings screen there could be Ajax requests triggered to validate the latest URL of each supported template type. That may be overkill to start with, so perhaps the best thing would be upon switching the mode to obtain the first post type that is supported by AMP, and obtain the first published post of that type that has AMP enabled, and then re-validate that URL. When the page then reloads there will be validation results available to show. |
if ( isset( $message ) ) { | ||
$wp_settings_errors[ $key ]['message'] = $message; // WPCS: Global override OK. | ||
// Ensure that this notice does not display again. | ||
update_user_meta( get_current_user_id(), $meta_key, true ); |
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.
We can remove the user meta flag. The notice should be shown each time the user changes the mode.
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.
Good point. 3a75250 removes the user meta as a condition of displaying this message.
} | ||
|
||
foreach ( $wp_settings_errors as $key => $setting ) { | ||
if ( 'general' === $setting['setting'] && 'settings_updated' === $setting['code'] ) { |
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.
If you call add_settings_error()
inside the option sanitizer callback, where we can detect the mode change, then this will get stored in a transient to then automatically be displayed with the admin_notices
when the page reloads.
What this won't do is hide the default settings updated notice.
Note that add_settings_error()
has a $type
parameter which can be "updated"
, so not an error at all.
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.
Great idea. cc2e62f uses add_settings_error()
in the sanitize_callback
.
Though I'm not sure why, it seems like the default message doesn't display when this is added.
As Weston mentioned, it's not necessary to hide this after the first time it shows
Thanks to Weston's suggestion, add this in the sanitize_callback for the option. Now, updating other options like 'Serve all templates...' won't display this notice.
Validating On Switching Template Modes Hi @westonruter,
Good idea, it would make sense to validate a URL on switching template modes.
|
@kienstra using In reality, the And yes, if there are no unaccepted validation errors on the URL then that “Review Errors” link should be removed. |
Sorry For Delay, Will Apply Today Hi @westonruter, |
…dd/1399-view-as-amp
Here's where I'm going with the messages. They vary based on the mode switched to, and there are links to view either the validated URL on the site, and/or to view the validation errors for that URL. Success message when activating native mode:Message when enabling paired mode but there are validation errors blocking it:When activating classic mode: |
…ed post types and templates
2c6d27a
to
75e6905
Compare
Todos include:
It might be best to only display this message when one of the template modes changes.
Closes #1399