-
Notifications
You must be signed in to change notification settings - Fork 8
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
Migrate over GEM notice support #21
Conversation
@@ -545,15 +545,6 @@ public function display_settings_page() { | |||
|
|||
<?php if ( ! empty( $forms->signups ) ) : ?> | |||
<div id="forms" class="panel"> | |||
<h3><?php esc_html_e( 'Reach Your Fans', 'godaddy-email-marketing' ); ?></h3> |
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.
@EvanHerman Why did you remove that?
add_action( 'init', array( $this, 'register_shortcode' ), 20 ); | ||
add_Action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) ); | ||
add_action( 'admin_notices', array( $this, 'action_admin_notices' ) ); | ||
add_action( 'wp_ajax_dismiss_gem_notice', array( $this, 'delete_wpem_gem_notice_option' ) ); |
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.
@EvanHerman We can reduce the spacing between the filter name and the array. Only 1 space between the comman of the biggest filter name.
add_action( 'init', array( $this, 'init' ) ); | ||
add_action( 'widgets_init', array( $this, 'register_widget' ) ); | ||
add_action( 'init', array( $this, 'register_shortcode' ), 20 ); | ||
add_Action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) ); |
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.
@EvanHerman I think there is a typo in add_Action
.
*/ | ||
public function register_admin_scripts() { | ||
|
||
if ( get_option( 'wpem-gem-notice' ) ) { |
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.
@EvanHerman Might be better to use an early return statement here.
if ( ! get_option( 'wpem-gem-notice' ) ) {
return;
}
* Displays the admin notice. | ||
*/ | ||
public function action_admin_notices() { | ||
|
||
if ( get_option( 'wpem-gem-notice' ) ) { |
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.
@EvanHerman Let's add a private function to get rid of this if
. $this->display_gem_notice
or something that makes sense.
/** | ||
* Delete the wpem-gem-notice option from the database | ||
* | ||
* @return boolean |
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.
@EvanHerman This function doesn't return a boolean.
<?php | ||
printf( | ||
__( 'Your website has a superpower: Email marketing. %1$s.', 'gd-system-plugin' ), | ||
'<a href="' . admin_url( 'options-general.php?page=gem-settings' ) . '">' . __( 'Learn More', 'gd-system-plugin' ) . '</a>' |
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.
@EvanHerman The text domain is not the right one.
@@ -0,0 +1,15 @@ | |||
/** |
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.
@EvanHerman Do we even need this file? I see we're using the .is-dismissible
class already on the notice. Does the dismiss functionality not work out-of-the-box?
cf. https://make.wordpress.org/core/2015/04/23/spinners-and-dismissible-admin-notices-in-4-2/
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.
@fjarrett I think we do since .is-dismissible only adds the X and the animation and nothing else.
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 need to fire the ajax somehow so the alert doesn't come back
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.
The dismiss function works out of the box, but it only hides the container. The option will still exist in the database causing the notice to display again.
This file fires an AJAX function that removes the option from the database, preventing the notice from displaying on subsequent page loads.
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 like that we have to do so much for this. Seems like it should be simpler...
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.
@jonathanbardo @EvanHerman why not just delete the wpem_gem_notice_option
on shutdown
if we know it exists? Then the message would fire only once the first time you go to the Admin, and go away with a click of the X or reload of any page.
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.
@fjarrett We can go that route, but I was worried that the notice would get overlooked after the first page load. It is less code that route. If you think that would be best I can adjust the PR accordingly.
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.
@EvanHerman I say yes because it seems to still meet the requirements and is way less code to maintain. @jonathanbardo What do you think?
'</a>' | ||
); | ||
?> | ||
</p> |
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.
@EvanHerman Was removing this text from the Settings page part of the scope?
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.
@fjarrett No, I think I originally forked this from another branch that didn't yet have this block of code.
@@ -151,6 +158,7 @@ public function init() { | |||
|
|||
// Initialize settings. | |||
if ( is_admin() ) { | |||
$this->display_gem_notice = get_option( 'wpem_gem_notice' ); |
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.
@EvanHerman Seems like we should be able to look for this inside the action_admin_notices
method and don't need this private property at all. Or did you already try that?
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.
@fjarrett You're right. This was originally placed in a private object because it was used in more than one location (DRY). Without the AJAX this is un-necessary. Removing it now.
</div> | ||
|
||
<?php | ||
|
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.
@EvanHerman I say we just delete the option right here after displaying the notice.
@jonathanbardo As discussed this is migrated over from the system plugin branch.
New functions and files have been introduced, the version has been bumped to.1.1.4
and the readme.txt has been updated accordinglyUpdate:
An informational notice is displayed back to the user on the initial dashboard page load, and then
wpem_gem_notice
option is deleted from the database to prevent subsequent page loads.Note: Needs translations.
Original PR:
Display an admin notice with information about the GEM plugin on fresh WordPress installs.
This is a persistent notice, with the ability to dismiss. Once the 'x' has been clicked, the notice will no longer appear back to the user.
The .pot file needs to be updated with the new strings.