Skip to content

Update INN/wordpress-mailchimp-tools submodule, and diverse other updates#139

Merged
benlk merged 38 commits intodevelopfrom
136-update-wordpress-mailchimp-tools
May 10, 2019
Merged

Update INN/wordpress-mailchimp-tools submodule, and diverse other updates#139
benlk merged 38 commits intodevelopfrom
136-update-wordpress-mailchimp-tools

Conversation

@benlk
Copy link
Copy Markdown
Collaborator

@benlk benlk commented Mar 7, 2019

Changes

This PR merges the last couple year's work from the WordPress Mailchimp Tools repo into this plugin. Resolves #136

Notable change from https://github.com/INN/wordpress-mailchimp-tools/commits/master:

Also:

Testing

Can these steps still be followed? https://github.com/INN/link-roundups/blob/master/docs/mailchimp.md

Why

To address several PHP errors and notices in the WordPress MailChimp Tools.

To support the new version of the MailChimp API, introduced in 2017: https://mailchi.mp/f2bbb62b3016/were-shutting-down-api-11-12-and-13

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented Mar 7, 2019

@kaylima assigning this to you for several tasks:

  1. Install the plugin from this zip (this is the v0.5-rc1 tag created today):
    wp-release.zip
  2. Can the instructions at https://github.com/INN/link-roundups/blob/master/docs/mailchimp.md be followed with a testing Mailchimp account?

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 1, 2019

The WordPress Mailchimp API submodule https://bitbucket.org/mailchimp/mailchimp-api-php hasn't been updated since 2015.

The Mailchimp API settings block seen in https://github.com/INN/link-roundups/blob/136-update-wordpress-mailchimp-tools/docs/mailchimp.md isn't appearing, in my specific install, at this time. This appears to be because my install lacks the entire vendor/ directory of components, which was present in wp-release.zip above. I don't know where or how that came from, and git submodule update --init --recursive is failing to create at least one submodule that should be in the vendor/ directory.

Next steps:

@benlk benlk self-assigned this May 1, 2019
@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 1, 2019

Correction: the MailChimp settings page is no longer in Link Roundups > Options; it's in Settings > MailChimp Settings. This is true of both the pure-git-clone branch and the wp-release.zip install above.


Edited 2019-05-02 to add: This, too, was caused by 675a1631f85cb056ca183206749e1cf60b9bc498's removal of a lot of code into the INN/wordpress-mailchimp-tools module

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 1, 2019

After enabling the MailChimp API key in the energynews.test site settings, the site begins timing out when trying to reach https://energynews.test/wp-admin/edit.php?post_type=roundup&page=roundup_mailchimp_settings

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 1, 2019

The timing-out page doesn't come from this plugin directly; it's generated by the WordPress MailChimp Tools:

https://github.com/INN/wordpress-mailchimp-tools/blob/04f246d463053693bcbd355fb23ec3533a7d27bb/inc/admin/class-mailchimp-post-type-settings.php#L21

I'm guessing this is because the API query to get the list of campaigns, which runs on every fetch of the page, is timing out:

https://github.com/INN/wordpress-mailchimp-tools/blob/04f246d463053693bcbd355fb23ec3533a7d27bb/inc/admin/class-mailchimp-post-type-settings.php#L43-L50

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 1, 2019

The Mailchimp Tools Settings Page only displays 10 templates; the account I'm testing with has more than 10.

  • increase that beyond 10
  • sort that list alphabetically/ASCIIbetically

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 2, 2019

  • increase that 10 count in the same spot in the post editor

benlk added a commit to INN/wordpress-mailchimp-tools that referenced this pull request May 2, 2019
…admin settings page's list of templates: 100, sorted by name

For INN/link-roundups#139 (comment)
@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 2, 2019

Draft created? Yes.
Send a drafted campaign? Yes.
Campaign works as described? No.

Screen Shot 2019-05-01 at 21 32 13

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 2, 2019

So it looks like 675a163 removed this bit by removing the entire inc/lroundups/mailchimp-admin.php:

function _lroundups_render_mailchimp_template( $source, $post ) {
	$author = get_user_by( 'id', $post->post_author );

	$tags = array(
		'*|ROUNDUPLINKS|*' 		=> apply_filters( 'the_content', $post->post_content ),
		'*|ROUNDUPTITLE|*' 		=> $post->post_title,
		'*|ROUNDUPAUTHOR|*' 	=> $author->display_name,
		'*|ROUNDUPDATE|*' 		=> get_the_date( '',$post->ID ),
		'*|ROUNDUPPERMALINK|*' 	=> get_post_permalink( $post->ID )
	);

	foreach ( $tags as $tag => $value )
		$source = str_replace( $tag, $value, $source );

	return $source;
}

That commit just outright removed the file, and the file doesn't appear to have been replaced. Nor was the functionality in there.

That was release v0.4.

I remember us having bug reports about it, but I can't find an issue for it.

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 2, 2019

In https://secure.helpscout.net/conversation/573233977/1940?folderId=1259183 on May 30, 2018:

I wanted to make sure that MailChimp merge tags worked, and they do in the single-column templates we were experimenting with (Sherry made one and I made an additional one to troubleshoot). Neither will pull in the link roundup tags. I tried in caps and in all lowercase in case it was a syntax error on my part. None of the other link roundup tags were working for me either (*|ROUNDUPAUTHOR|*, etc.). Do you have any idea of where we went wrong?

#146

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 2, 2019

#146 should be fixable by re-adding that removed function.

What's not clear there yet is:

  • if anything else should be re-added.
  • where in the filesystem this should go.

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 2, 2019

The removed function was applied here:

		/**	
		 * Replace the template tags in the MailChimp post	
		 */	
		$html = _lroundups_render_mailchimp_template( $template_info['source'], $post );	
 		$campaign_content = array(	
			'html' => $html, // the content!	
			'text' => '' // Leave blank for the auto-generated text content	
		);

The analogous functionality in the current WP MC Tools is:

https://github.com/INN/wordpress-mailchimp-tools/blob/0ff5674b85b8604895a1022c9d0c7f83cf3a0c10/inc/admin/class-mailchimp-campaign-editor.php#L234-L242

But there's no way to configure the parameters that are set on that email. So:

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 7, 2019

It is currently creating the email, but entirely replacing the content of the email with the *|ROUNDUPLINKS|* content rather than filling the template areas. This should be investigated.

Right now it's using a drag-and-drop template with a block that contains the following:

This should be the roundup title:
<section mc:edit="ROUNDUPTITLE">This should be replaced with the roundup title</section>
This should be the roundup author:

<section mc:edit="ROUNDUPAUTHOR">This should be replaced with the roundup author</section>
This should be the roundup date:

<section mc:edit="ROUNDUPDATE">This should be replaced with the roundup date</section>
This should be the roundup links:

<section mc:edit="ROUNDUPLINKS">This should be replaced with the roundup links</section>
This should be the roundup permalink:

<section mc:edit="ROUNDUPPERMALINK">This should be replaced with the roundup permalink</section>

<hr />
<h1 style="text-align: center;">*|ROUNDUPTITLE|*</h1>

<p><em>*|ROUNDUPAUTHOR|* &mdash; *|ROUNDUPDATE|*</em></p>
*|ROUNDUPLINKS|*

<p>Originally posted at *|ROUNDUPPERMALINK|*</p>

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 7, 2019

It's not possible to get the whole default content of a template via the API.

The closest thing is https://developer.mailchimp.com/documentation/mailchimp/reference/templates/default-content/, which returns the default content of the various editable areas defined in the template, but not the whole body content of the campaign. Therefore, the approach taken in the previous version of the WordPress MailChimp Tools to set the $html parameter to the post content will not work for the Link Roundup Plugin's purposes.

The filter introduced in INN/wordpress-mailchimp-tools@4e768f7 will have to be used to set the HTML parameter on the campaign content, if the user of the WMT package desires to have that set.

Because the whole content cannot be accessed, the idea of filtering that content for the various merge tags in this plugin to do a search and replace for this plugin's desired content output is no longer valid.

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 8, 2019

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 8, 2019

Consolidating earlier checklists:

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 10, 2019

  • get the WMT audience box to allow un-targeting a targeted subgroup.

@benlk
Copy link
Copy Markdown
Collaborator Author

benlk commented May 10, 2019

🎉

Next step: Someone please test that this works for them.

@benlk benlk merged commit bbd696c into develop May 10, 2019
@benlk benlk deleted the 136-update-wordpress-mailchimp-tools branch May 10, 2019 21:33
@benlk benlk mentioned this pull request May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant