Skip to content

Instantly share code, notes, and snippets.

@evrpress
evrpress / gist:c57da52a3848305524e8
Last active January 13, 2016 15:56
Replacing certain strings
function my_mymail_text_strings( $translated_text, $org_text, $domain ) {
if($domain != 'mymail') return $translated_text;
switch ( $org_text ) {
case 'Search for Text to Replace' :
$translated_text = 'Replace it with this text';
break;
}
return $translated_text;
}
@evrpress
evrpress / dynamic_tag.php
Last active January 20, 2016 14:56
Dynamic tags with option example
if ( function_exists( 'mymail_add_tag' ) ) {
function mytag_function($option, $fallback, $campaignID = NULL, $subscriberID = NULL){
if(1 == $option){
$link = 'http://exmaple.com/link1';
}else if(2 == $option){
$link = 'http://exmaple.com/link2';
}else if(3 == $option){
$link = 'http://exmaple.com/link3';
}
@evrpress
evrpress / gist:eda7d379b9342663138c
Created February 23, 2016 13:22
Add custom header to MyMail
function add_custom_header_to_mymail($obj){
$obj->add_header('X-Custom-Header', 'Custom Value');
}
add_action('mymail_presend', 'add_custom_header_to_mymail');
@evrpress
evrpress / gist:c2cc116114299a9ea79d
Last active August 7, 2016 09:48
Uppercase first and lastname
function my_uppercase_name( $data ) {
if(isset($data['firstname'])) $data['firstname'] = ucwords($data['firstname']);
if(isset($data['lastname'])) $data['lastname'] = ucwords($data['lastname']);
return $data;
}
add_filter( 'mymail_verify_subscriber', 'my_uppercase_name' );
add_filter( 'mailster_verify_subscriber', 'my_mailster_verify_subscriber' );
function my_mailster_verify_subscriber( $entry ) {
//verify subscriber with custom methods
return $entry;
}
@evrpress
evrpress / lastname
Last active February 27, 2017 09:56
Populates the last name if present in the first name field
add_filter( 'mailster_verify_subscriber', function( $entry ) {
if ( isset( $entry['firstname'] ) ) {
$names = explode( ' ', $entry['firstname'] );
$entry['firstname'] = array_shift( $names );
if ( ! empty( $names ) ) {
$entry['lastname'] = implode( ' ', $names );
}
}
@evrpress
evrpress / gist:ecb2f56d10f08ead549d2e3a7b20cad7
Last active February 27, 2017 09:57
List only Unsubscribe
function mailster_lists_only_unsubscribe($subscriber_id, $campaign_id){
//unsubscribe user if campaign doesn't exists or isn't set
if(!mailster('campaigns')->get($campaign_id)) return;
$subscriber = mailster('subscribers')->get($subscriber_id);
if($subscriber){
//change back to subscribed (silently)
mailster('subscribers')->change_status($subscriber_id, 1, true);
//get lists from the campaign
@evrpress
evrpress / gist:0233566f5ec2a14f9db743c8bb271870
Last active February 27, 2017 09:58
Change the HTML of MyMail Forms
add_filter( 'mailster_form', 'change_mailster_form_html', 10 , 3 );
function change_mailster_form_html( $html, $form_id, $form ) {
//do some replacements
return $html;
}
@evrpress
evrpress / Add user to list after click on link
Last active February 27, 2017 09:58
Assigns a subscriber to a certain list if a certain link has been clicked
@evrpress
evrpress / add_class_if_subscriber
Last active February 27, 2017 09:59
add body class if current user is subscriber
add_filter( 'body_class', 'add_class_if_subscriber' );
function add_class_if_subscriber( $classes ) {
$user_ID = get_current_user_id();
$subscriber = mailster('subscribers')->get_by_wpid($user_ID);
if($subscriber){
$classes[] = 'is-mailster-subscriber';
}
return $classes;
}