Skip to content
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

Merged
merged 6 commits into from
Mar 27, 2017
Merged

Conversation

stoyan0v
Copy link
Contributor

@stoyan0v stoyan0v commented Feb 9, 2017

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:

  • Go to Widgets
  • Find "MailChimp Subscriber Popup" and add the widget to any sidebar
  • Add the following embedcode in "Code" field:
<script type="text/javascript" src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us11.list-manage.com","uuid":"1ca7856462585a934b8674c71","lid":"2d24f1898b"}) })</script>
  • Open the front-end and you should see the popup
  • If the popup doesn't appear for some reason, check if the code exists in the sidebar. It's easier if you add the widget between two others that have some content/html.

cc @jeherve, @eliorivero

@stoyan0v stoyan0v changed the title Add/mailchimp widget Add MailChimp Widget Feb 9, 2017

// Process the shortcode only, if exists.
if ( ! empty( $matches[0] ) ) {
echo do_shortcode( $matches[0] );
Copy link
Member

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?

Copy link
Contributor Author

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>
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

?>

<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'code' ) ); ?>"><?php esc_html_e( 'Code:', 'jetpack' ); ?></label>
Copy link
Member

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.

Copy link
Contributor Author

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

@jeherve jeherve added [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Feb 9, 2017
@stoyan0v stoyan0v force-pushed the add/mailchimp-widget branch from c4ebb73 to 95154d1 Compare February 10, 2017 19:20
@jeherve jeherve added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Feb 10, 2017
Copy link
Member

@rcoll rcoll left a 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!

@rcoll rcoll added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Mar 27, 2017
@rcoll
Copy link
Member

rcoll commented Mar 27, 2017

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.

@briancolinger briancolinger merged commit de9071a into Automattic:master Mar 27, 2017
@matticbot matticbot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Mar 27, 2017
@jeherve jeherve added [Status] Needs Testing We need to add this change to the testing call for this month's release [Status] Has Changelog and removed [Status] Needs Changelog [Status] Needs Testing We need to add this change to the testing call for this month's release labels Mar 27, 2017
jeherve added a commit that referenced this pull request Mar 28, 2017
samhotchkiss pushed a commit that referenced this pull request Mar 29, 2017
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants