Skip to content

Contributing new snippets

Kyle edited this page Jun 11, 2018 · 1 revision

To add a new snippet to the library, create a new HTML file within the appropriate snippet category's directory. Those directories will be prefixed with an "_" and are named based on the type of snippet (downloads, emails, checkout, extensions, etc.).

Once you have created the new HTML file and named the file appropriately (like reorder-downloads-list.html), edit the file and insert the Front Matter information at the top of the file. You can just copy from another snippet file if you want. The front matter will look something like this:

---
layout: snippet
title: Custom Email Template
description: Creates a custom email template for EDD emails.
collection: emails
---

Below that, you will want to add your PHP which should always be formatted as a complete WordPress plugin. Here's an example:

<?php
/*
 * Plugin Name: Easy Digital Downloads - Customize User Verification Email
 * Description: Modifies the email sent to customers to verify their account.
 * Author: Easy Digital Downloads
 * Author URI: https://easydigitaldownloads.com/
 * Version: 1.0
 */

function jp_customize_verification_email( $message, $user_id ) {
	$user_data = get_userdata( $user_id );
	$url       = edd_get_user_verification_url( $user_id );
	$from_name = edd_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
	$message   = sprintf( __( "Howdy %s,\n\nYour account with %s needs to be verified before you can access your purchase history. <a href='%s'>Click here</a> to verify your account and get access to your purchases.", 'edd' ), $user_data->display_name, $from_name, $url );
	return $message;
}
add_filter( 'edd_user_verification_email_message', 'jp_customize_verification_email', 10, 2 );

Note: Please maintain consistency across all snippets when it comes to format and provided information. The plugin header should contain:

  • Plugin Name (usually should be the same as the title from the front matter section)
  • Description (usually should be the same as the description from the front matter section)
  • Author (Easy Digital Downloads, unless contributed by a non-employee
  • Author URI (https://easydigitaldownloads.com)
  • Version

Once you've completed the file, just commit and you're done!

Clone this wiki locally