AutoChimp 2.12 – “Class ‘XXX’ not found” has been fixed

Everyone who has wanted to upgrade to the latest version of AutoChimp can do so now. You may have run into an error like this before:

Fatal error: Class ‘SyncWPMembers’ not found in /<<PATH_TO_WORDPRESS>>/wp-content/plugins/autochimp/autochimp-plugins.php on line 220.  Note that a different ‘Class’ may appear for you depending on the other plugins that you have installed on your site.

If so, you’re in luck.  This bug has been fixed.  Usually, a major new release of AutoChimp will contain some errors based on different configurations of servers, hosting companies, PHP versions, etc.  And, it usually takes a couple of minor release updates to finally fix the bugs and standardize the release.  AutoChimp 2.12 does this.  Enjoy!

Problems with AutoChimp 2.10

Hello AutoChimpers!  Seems that for the most part AutoChimp is working well for everyone.  However, many people are running into one or two problems:

  1. Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /<<PATH_TO_WORDPRESS>>/wp-content/plugins/autochimp/autochimp.php on line 841
  2. Fatal error: Class ‘SyncWPMembers’ not found in /<<PATH_TO_WORDPRESS>>/wp-content/plugins/autochimp/autochimp-plugins.php on line 220.  Note that a different ‘Class’ may appear for you depending on the other plugins that you have installed on your site.

As for the fixes, here’s what we are going to do:

  1. This is an issue with older versions of PHP.  If you upgrade to PHP 5.3.x as suggested on PHP’s site (search for “5.2″), this problem will go away.  Unfortunately, there is not a better way to notify users of this problem other than the “fatal error” and the cryptic message because the issue is in parsing the PHP file, not running the code in the PHP file.  If you use HostGator, here’s their instructions on how to upgrade PHP 5.3.  If you’re not so technically inclined, your support staff can easily and quickly do this for you.
  2. For some reason, on some system, AutoChimp plugins aren’t loaded when calling a static method on that class.  So, all we need to do is ensure that whenever a static method is about to be called, we include the plugin files.

If you are running into these errors, then upgrade to 2.12.

Uninstalling and reinstalling 2.10 or 2.11 makes no difference (FYI, this practice, a leftover from the clunky install/uninstall model from MS Windows, almost never makes a difference in an environment such as WordPress.  It’s a shame that Windows leaves us this legacy.).

How to write an integration for AutoChimp

Do you have a favorite plugin that you use to help users to signup?  Is this plugin also not supported?  This is a very common scenario given how many plugins are out there and how fast the WordPress world changes.  There are always new plugins being developed and it’s often not easy for AutoChimp to keep up with these changes (there’s always lots of other work to do here).

Fortunately, with the new release of AutoChimp (2.1), there is now a new framework in place that makes it much easier to add support for your favorite plugin to AutoChimp.  You no longer need to read all of the code and take all that time needed to understand what to insert and where.  You also don’t need to contact us in order to do this.  Once you create your script, you just drop it into the “plugins” folder and you’ve got your integration!  If you want your integration to become a permanent member of the AutoChimp release, then you do need to have us check it into the source repository, but that is very little effort for me (the main dev on AutoChimp).  And, that’s the whole purpose of this update!  Because it’s so hard to find time to help folks out with AutoChimp, this is one way to make it much easier for folks to write solutions for themselves.  And, there are examples to help you along the way.  How do you do this?  Read on!

With the 2.1 release, AutoChimp supports three types of plugins (aka “integrations”).  Yes, that is getting a little confusing – AutoChimp itself is a plugin, but you can also write plugins for AutoChimp!  The three types of plugins are:

  1. Sync plugins – this is the most common and requested plugin.  This is a plugin to support another WordPress plugin that extends the registration process by providing more user data fields.  AutoChimp distills this new information down into a structure that MailChimp can understand and synchronizes that data with MailChimp.
  2. Publish plugins – A publish plugin creates different types of posts.  For example, perhaps you have a WordPress plugin that creates another post type, like “Concerts”.  You can write a plugin so that AutoChimp becomes aware of this type and can instruct MailChimp to create Concert campaigns.
  3. Content plugins – This is the most simple type of plugin that supports a WordPress plugin with a special “shortcode” that the WordPress plugin uses to generate special content.  For example, maybe you have a plugin that generates nice YouTube videos in your posts.  If you want your MailChimp campaigns also have those nice videos as well, you can write a content plugin to support the WordPress plugin for YouTube content.

If you’re still reading at this point, I’m assuming that you’re a developer.  But, I’ve tried to make this as easy as possible so if you’re new, you still might be able to follow along.

All plugins for AutoChimp are located in AutoChimp’s “plugins” subfolder.  If you look at that folder, you’ll see a few Sync plugins (the file names are prefixed with “Sync”) and at least one Publish and one Content plugin (whose filenames are prefixed with “Publish” and “Content” respectively).  Each plugin is represented by one file.

So, to start, give your new plugin’s filename one of the above prefixes.

The remainder of your filename together with one of these prefixes will form the name of a class in that file which implements your functionality.  Your class should also be derived from one of the ACPlugin-derived classes which is in the file “autochimp-plugins.php”.  Naturally, the three ACPlugin subclasses are named:  ”ACSyncPlugin”, “ACPublishPlugin”, and “ACContentPlugin”.  So, for example, the sync plugin “SyncWPMembers.php” has a class derived from ACSyncPlugin named “SyncWPMembers”.

Got that?  Make sure your class derives from the right ACPlugin-derived class and is named the same thing as your filename.

Now that you’ve done that, you’re “plugged in” to the architecture of AutoChimp and AutoChimp will now start to ask objects of your class to do some work.  The next step is to implement the necessary methods in ACPlugin and the ACPlugin-derived class that you extend.

At this point, the best instructions can be found in the “autochimp-plugins.php” file.  Start by reading the comments for the ACPlugin class followed by the comments for the class you’re deriving from.  Then, have a look at one of the existing plugin files and you’ll see what you need to do.  In many cases, there are AutoChimp helper functions that you can use to do a lot of the work for you.  After all, almost all of the supported WordPress plugins do the same thing.  The one thing that makes them different is that they organize their data.  Your plugin only has two main responsibilities:

  1. Display a UI that the user can use to instruct how he or she wants to use the WordPress plugin and…
  2. Translate that WordPress plugin’s data into a MailChimp understandable format.

When you distill it down to those responsibilities, you’ll see that there’s really not that much work for you.  It’s certainly way easier that it used to be so enjoy!  And remember, if you write your own plugin, let us know so we can ultimately include it as a permanent part of the AutoChimp release.

AutoChimp 2.1 is coming soon

Status

AutoChimp 2.1 will include these new features:

Support for these third party WordPress plugins:

  1. WP-Members plugin
  2. Wishlist Member plugin
  3. Events Manager

Campaign Updates:

  1. Redesigned UI allows you to have fine control on how your campaigns are created.
  2. Support for custom post types.  The Events Manager plugin is an example of this in action:  You can assign your own event categories to posts from Events Manager and then create campaigns from them.

Internals:

  1. The guts of AutoChimp was reworked to allow other developers to easily contribute to AutoChimp.  You no longer need to understand the full extent of AutoChimp to extend the plugin.  You can now just focus on the core of your integration and the AutoChimp internals will do the rest of the work for you.  If you’re a WordPress developer, see this post and the new file autochimp-plugins.php for more.

AutoChimp 2.0 Seeking Contributions!

AutoChimp 2.0 needs your support!

There have been no shortage of requests for Autochimp.  So, in the spirit of helping the community out, AutoChimp 2.0 is seeking contributions from the MailChimp community, especially those who use MailChimp in conjunction with WordPress.

AutoChimp 2.0 is now a “crowd-funding” project on Indiegogo, a site which brings like-minded people together to help raise funds for projects that they care about.

This is great for AutoChimp because so many people ask for the same features.  With “crowd-funding”, we can spread the cost of development around a large number of people, thereby eliminating the need to have just one person fund features.  That’s how AutoChimp funded many features in the past.  Believe me, crowd-funding is a great step forward!

AutoChimp chose a modest fund amount of $1500 mainly because this is our first attempt at crowd-funding.  For sure, there will be plenty of learning opportunities along the way.  If all goes well, then we’ll be able to crank through version 2.0 in about a month as well as be set up for future enhancements.

You can visit AutoChimp’s crowd-funding page on Indiegogo.com here:

Be sure to check out the bonuses!  We hope you can contribute!

Oh, and one other thing:  If AutoChimp 2.0 does not meet its funding goal, then all contributions will be refunded.  It’s all or nothing.  Either AutoChimp 2.0 gets funded and built, or you get your money back!

Call Me in China 2.0 Released

Call Me in China released a big and bold new version, which we’re calling 2.0.  Technically, it’s really a 3.0 version, but because of the new design, and the fact that 1.0 was really just a test beta version, we’re calling it 2.0.

OK, now that I got that background stuff out of the way, here are the big new features – and they are quite big:

  • Perhaps the biggest change is a greatly expanded inventory of home country numbers.  You can now pick a number in specific regions of your home country, even down to the granularity of small towns.
  • A growing list of supported home countries.  We’ve added a couple more for this release with more on the way.  It’s easier now than ever before to find a number that will fit what you’re looking for.
  • For some strict countries that require documentation in order to receive a number, we’ve streamlined the process to ensure that you get your number as quickly as possible, in 99% of cases this happens in less than 24 hours.  For other countries, of course, you can start receiving calls on your new Call Me in China number instantly.

There were several updates on the backend, especially on the admin side which makes it easier for us to provide service to our customers.  It’s also easier to understand trends.  We also have some new ways to offer benefits and bonuses to our customers.

Let me test out this affiliate link to, just for fun.  Send us a mail if you’re interested in the affiliate program.


Finding Info

The first seven years or so of my career as a software developer were good ones.  One way I felt that I distinguished myself from others wasn’t anything typical like coding up some super efficient algorithm (in fact, I’m quite bad at that), but rather the ability to hunt down information.  Back then Google was just in its infancy.  The primary source of info was the MSDN collection of CDs, books, and magazines, all of which I read and I became very good at searching.  Whenever there was a hard problem facing our team, I just went to these sources and eventually found a solution.

Even with the advent of Google and other search mechanisms, I don’t feel I have the edge that I used to, but here’s a recent example in WordPress of how I hunted down info about solving a problem for a client.  He needed to present admins with a list of templates installed in the user’s theme.  Easy problem, but how do you go about finding the answer?

Thankfully, unlike other open source techs I use now, WordPress is a very clean project where finding answers is pretty easy.  The first idea I had was:  ”Obviously, this must be easy because WordPress itself does this.”  Have a look at the template section of the “page edit” admin page:

This “Page Attributes” area is a box on the right side of the page.  What I usually do in this case is search the WordPress codebase for a visual text string that is likely to turn up only a few times.  In this case, the options weren’t so go, so I just went with the title:  ”Page Attributes:”.  Fortunately, there were results in the file edit-form-advanced.php:

if ( post_type_supports($post_type, 'page-attributes') )
	add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', $post_type, 'side', 'core');

That doesn’t quite get us there, but you can see there’s a function call to “add_meta_box”, so let’s search for “function add_meta_box”.  The results are found in meta-boxes.php:

<p><strong><?php _e('Template') ?></strong></p>
<label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
<option value='default'><?php _e('Default Template'); ?></option>
<?php page_template_dropdown($template); ?>
</select>

OK, getting closer.  There’s a function called page_template_dropdown().  Searching the WordPress Codex doesn’t yield much on this function, so let’s search the source again.  This time “function page_template_dropdown”.  Here are the results:

function page_template_dropdown( $default = '' ) {
	$templates = get_page_templates();
	ksort( $templates );
	foreach (array_keys( $templates ) as $template )
		: if ( $default == $templates[$template] )
			$selected = " selected='selected'";
		else
			$selected = '';
	echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
	endforeach;
}

No we’re getting close!  See, there’s a function called “get_page_templates()” which is obviously returning a list of page templates.  Exactly what we want.  At this point, I assumed that there was a documented function in the Codex for this function.  There is, but there’s almost no information on it.  So, it’s time to go to the code one more time.  And of course, I search for “function get_page_templates”.  Here are the results (in theme.php):

/**
 * Get the Page Templates available in this theme
 *
 * @since 1.5.0
 *
 * @return array Key is the template name, value is the filename of the template
 */
function get_page_templates() {
	$themes = get_themes();
	$theme = get_current_theme();
	$templates = $themes[$theme]['Template Files'];
	$page_templates = array();

	if ( is_array( $templates ) ) {
		$base = array( trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()) );

		foreach ( $templates as $template ) {
			$basename = str_replace($base, '', $template);

			// don't allow template files in subdirectories
			if ( false !== strpos($basename, '/') )
				continue;

			if ( 'functions.php' == $basename )
				continue;

			$template_data = implode( '', file( $template ));

			$name = '';
			if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) )
				$name = _cleanup_header_comment($name[1]);

			if ( !empty( $name ) ) {
				$page_templates[trim( $name )] = $basename;
			}
		}
	}

	return $page_templates;
}

Great!  Exactly what we need.  You can even see the code that implements the behavior as described in the guides on theme development:  That in order to register your template with the system, you just need to add comments at the beginning with the text “Template Name:”  All we need to do now is pop in this function to our code and we’re good to go!