Woocommerce custom emails without header and footer

Seems I’ve managed to find the solution. $mailer = $woocommerce->mailer(); must be called before the Get mail template function send_activation_link() { global $woocommerce; //My other code here…. $mailer = $woocommerce->mailer(); ob_start(); // Get mail template woocommerce_get_template(’emails/customer-reset-password-link.php’, array( ‘user_login’ => $user_login, ‘blogname’ => $blogname, ’email_heading’ => $email_heading, ‘key’ => $key )); // Get contents $message = … Read more

Two functions utilizing registration_errors filter

Identifying errors via error code Run add_user_to_SF with an earlier priority, to make it execute first add_filter( ‘registration_errors’, ‘add_user_to_SF’, 9, 3 );` Let’s assume you have two possible errors in your add_user_to_SF: function add_user_to_SF( $errors, $sanitized_user_login, $user_email ) { $has_errors = false; if ( /* some condition that should throw an error */ ) { … Read more

Plugin developement and SVN

Two things to note, URL requirement when registering plugin is currently worded as: Plugin URL (required, must be a link to a ZIP file of the working plugin) So you can simply put packed up plugin somewhere (your server, public Dropbox folder, etc) to provide it for review. It doesn’t have to be established site … Read more

Detect where custom post type is declared

Hook into registered_post_type and store the data from debug_backtrace(). The third entry should be the calling plugin. Sample code add_action( ‘registered_post_type’, ‘track_post_types’, 10, 2); function track_post_types( $post_type = NULL, $args = array() ) { static $tracked = array(); if ( ‘shutdown’ === current_filter() ) { print ‘<pre>$tracked = ‘ . esc_html( var_export( $tracked, TRUE ) … Read more

Common abstract class for plugins

Unfortunately there is no system in WordPress to handle dependencies and sharing components between extensions is a challenge. The possible solutions roughly are: make shared part a plugin and require each plugin to require it (and possibly auto install/activate) implement loader that will take care of processing versioning for shared part and take care of … Read more

How a deprecated function can crash WordPress site while upgrading

Where… The following files hold the deprecated functions: ~/wp-includes/deprectated.php ~/wp-includes/pluggable-deprectated.php … Take a look at them and then through their replacement functions, where the calls to _deprecated_function() happen. Why… Normally a crash shouldn’t happen. In the “real” PHP world, you’d get an E_DEPRECATED Warning. In WordPress you’ll get a trigger_error() return caused by _deprecated_function() calls. … Read more