-
Notifications
You must be signed in to change notification settings - Fork 815
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 MailChimp Widget #6344
Add MailChimp Widget #6344
Conversation
|
||
// Process the shortcode only, if exists. | ||
if ( ! empty( $matches[0] ) ) { | ||
echo do_shortcode( $matches[0] ); |
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 rely on the shortcode here, you'll need to make sure the shortcode is declared before to register this widget, otherwise this will fail as soon as someone disables the Shortcode Embeds module, or unregisters the shortcode.
Maybe you could check if the MailChimp_Subscriber_Popup
class exists in the jetpack_mailchimp_subscriber_popup_widget_init
function, before to register the widget?
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 catch. The check has been added, so the widget will not be registered when shortcode is missing for some reason.
$instance = wp_parse_args( $instance, array( 'code' => '' ) ); | ||
?> | ||
|
||
<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.
Maybe you could add a title to this widget?
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 think so. The widget displays a script tag only, so the title here is useless, since it will not be displayed.
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 doesn't display a widget in the traditional manner, so I would say no title is necessary.
modules/widgets/mailchimp.php
Outdated
?> | ||
|
||
<p> | ||
<label for="<?php echo esc_attr( $this->get_field_id( 'code' ) ); ?>"><?php esc_html_e( 'Code:', 'jetpack' ); ?></label> |
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.
It might be worth being more specific here: Code
does not explain what code the user has to enter here.
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.
Make sense. I've added a link to this page, similar to wordpress.com
c4ebb73
to
95154d1
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 works well and code looks fine to me. I do recommend a trim()
in the update
method to remove leading and trailing whitespace, but that's purely cosmetic. Thanks!
One other note - I'm not in love with the execution on this (using a widget to display a script tag with no widget content), but I don't really know of a better/quicker way. This does work fine and shouldn't break anything, but maybe we need a better strategy for these types of things. |
* Readme: remove old release and add skeleton for 4.8. * Changelog: add #6572 * Changelog: add #6567 * Changelog: add #6542 * Changelog: add #6527 * Changelog: add #6508 * Changelog: add #6478 * Changelog: add #6477 * Changelog: add #6249 * Update stable version and remove old version from readme. * Changelog: add 4.7.1 to changelog. * Readme: add new contributor. * Sync: update docblock @SInCE version. Related: #6053 * Changelog: add release post. * changelog: add #6053 * Changelog: add #6413 * Changelog: add #6482 * Changelog: add #6584 * Changelog add #6603 * Changelog: add #6606 * Changelog: add #6611 * Changelog: add #6635 * Changelog: add #6639 * Changelog: add #6684 * Changelog: add #6710 * Changelog: add #6711 * Changelog: add #5461 * Testing list: update Settings UI feedback prompt. Props @MichaelArestad * Changelog: add #6789 * Changelog: add #6778 * Changelog: add #6777 * Changelog: add #6775 * Changelog: add #6755 * Changelog: add #6731 * Changelog: add #6721 * Changelog: add #6705 * Changelog: add #6702 * Changelog: add #6671 * Changelog: add #6637 * Changelog: add #6582 * Changelog: add #6566 * Changelog: add #6555 * Changelog: add #6529 * Changelog: add #6344 * Changelog: add #5763 * Changelog: add #5503 * Changelog: update #6637 changelog. @see 40e115c#commitcomment-21523982 * Changelog: add #6699 * Changelog: add #6632 * Changelog: add #6769 * Changelog: add #6707 * Changelog: add #6590
Fixes #5942
Adds the MailChimp Subscribe Popup widget. It basically uses the
mailchimp_subscriber_popup
shortcode to add the script and I've tried to match the WordPress.com widget as much as possible.Testing instructions:
cc @jeherve, @eliorivero