array (
"title" => __( "Post tags", "alo-easymail" ),
"tags" => array (
"[POST-TITLE]" => __("The link to the title of the selected post.", "alo-easymail") ." ". __("This tag works also in the subject", "alo-easymail") . ". ". __("The visit to this url will be tracked.", "alo-easymail"),
"[POST-EXCERPT]" => __("The excerpt (if any) of the post.", "alo-easymail"). ( version_compare ( $wp_version , '3.3', '>=' ) ? " ". __("If it is empty, the beginning of post content will be used.", "alo-easymail") : "" ),
"[POST-CONTENT]" => __("The main content of the post.", "alo-easymail")
)
),
"easymail_subscriber" => array (
"title" => __( "Subscriber tags", "alo-easymail" ),
"tags" => array (
"[USER-NAME]" => __("Name and surname of registered user.", "alo-easymail") . " (". __("For subscribers: the name used for registration", "alo-easymail") ."). ". __("This tag works also in the subject", "alo-easymail").".",
"[USER-FIRST-NAME]" => __("First name of registered user.", "alo-easymail") . " (". __("For subscribers: the name used for registration", "alo-easymail") ."). ". __("This tag works also in the subject", "alo-easymail").".",
"[USER-EMAIL]" => __("Email address of subscriber", "alo-easymail") . ". "
)
)
);
return apply_filters ( 'alo_easymail_newsletter_placeholders_table', $placeholders );
}
/**
* Print table with tags summay
*/
function alo_em_tags_table ( $post_id ) {
$placeholders = alo_em_newsletter_placeholders();
if ( $placeholders ) :
foreach ( $placeholders as $type => $placeholder ) :
if ( isset( $placeholder['tags'] )) : ?>
$desc ) : ?>
$n_last_posts,
'order' => 'DESC',
'orderby' => 'date'
);
$args = apply_filters ( 'alo_easymail_placeholders_title_easymail_post_vars', $args, $post_id ); // Hook
$get_posts = get_posts($args);
if ( $get_posts ) {
echo esc_html( __("Choose a post", "alo-easymail") ). ": ";
echo ' ';
} else {
echo "" . esc_html( __("There are no posts", "alo-easymail") ) . "! ";
}
}
add_action('alo_easymail_newsletter_placeholders_title_easymail_post', 'alo_em_placeholders_title_easymail_post' );
/**
* alo newsletter custom email hooks
*/
function alo_em_zirkuss_custom_easymail_placeholders( $placeholders ) {
$warning_readonline = ( get_option('alo_em_publish_newsletters') == "no" ) ? " ".__( 'This tag now does not work because the online publication of newsletters is disabled', 'alo-easymail' ).": ". __( 'you can set it up in settings', 'alo-easymail' )."" : "";
$placeholders['easymail_subscriber']['tags']['[USER-UNSUBSCRIBE]'] = __ ( 'Text and URL to unsubscribe.', 'alo-easymail' ) . " (". __( 'You can customise this text in settings', 'alo-easymail' ) .".)";
$placeholders['easymail_subscriber']['tags']['[USER-UNSUBSCRIBE-URL]'] = __ ( 'URL to unsubscribe.', 'alo-easymail' );
$placeholders['easymail_newsletter']['title'] = __( "Newsletter tags", "alo-easymail" );
$placeholders['easymail_newsletter']['tags']['[READ-ONLINE]'] = __ ( 'Text and URL to the online version.', 'alo-easymail' ) . " (". __( 'You can customise this text in settings', 'alo-easymail' ) ."). " . __('The visit to this url will be tracked.', 'alo-easymail'). " ".$warning_readonline;
$placeholders['easymail_newsletter']['tags']['[READ-ONLINE-URL]'] = __ ( 'URL to the online version.', 'alo-easymail' ). " ". __('The visit to this url will be tracked.', 'alo-easymail'). " ". $warning_readonline;
$placeholders['easymail_newsletter']['tags']['[TITLE]'] = __ ( 'Title of the newsletter.', 'alo-easymail' );
$placeholders['easymail_newsletter']['tags']['[DATE]'] = __ ( 'Date of the newsletter.', 'alo-easymail' );
if ( current_theme_supports( 'post-thumbnails' ) ) $placeholders['easymail_newsletter']['tags']['[THUMB]'] = __ ( 'Post Thumbnail of newsletter', 'alo-easymail' );
$placeholders['easymail_newsletter']['tags']['[GALLERY]'] = __ ( 'Image gallery of newsletter', 'alo-easymail' );
$placeholders['easymail_site']['title'] = __( "Site tags", "alo-easymail" );
$placeholders['easymail_site']['tags']['[SITE-LINK]'] = __("The link to the site", "alo-easymail") .". ".__('The visit to this url will be tracked.', 'alo-easymail');
$placeholders['easymail_site']['tags']['[SITE-URL]'] = __ ( 'URL to the site.', 'alo-easymail' ).". ".__('The visit to this url will be tracked.', 'alo-easymail');
$placeholders['easymail_site']['tags']['[SITE-NAME]'] = __('Site Title');
$placeholders['easymail_site']['tags']['[SITE-DESCRIPTION]'] = __('Tagline');
if ( current_theme_supports( 'custom-logo' ) ) $placeholders['easymail_site']['tags']['[SITE-LOGO]'] = __('Logo');
if ( current_theme_supports( 'post-thumbnails' ) ) $placeholders['easymail_post']['tags']['[POST-THUMB]'] = __("Post Thumbnail", "alo-easymail");
$placeholders['easymail_post']['tags']['[POST-GALLERY]'] = __("The image gallery of the post", "alo-easymail") ;
return $placeholders;
}
add_filter ( 'alo_easymail_newsletter_placeholders_table', 'alo_em_zirkuss_custom_easymail_placeholders', 5 );
/**
* alo newsletter content
*/
function alo_em_zirkuss_newsletter_content( $content, $newsletter, $recipient, $stop_recursive_the_content = false )
{
if ( !is_object( $recipient ) ) $recipient = new stdClass();
if ( empty( $recipient->lang ) ) $recipient->lang = alo_em_short_langcode ( get_locale() );
// title
$subject = stripslashes ( alo_em_translate_text ( $recipient->lang, $newsletter->post_title, $newsletter->ID, 'post_title' ) );
$subject = apply_filters( 'alo_easymail_newsletter_title', $subject, $newsletter, $recipient );
// use the email theme only when emailing the
// newsletter. otherwise use the default
// wordpress theme to display the newsletter.
if ( isset( $recipient->ID ) )
{
// If newsletter publication online available, create the message to read the newsletter online
if ( get_option('alo_em_publish_newsletters') == "no" ) {
$viewonline_url = $viewonline_msg = $trackable_viewonline_url = "";
} else {
$viewonline_msg = alo_em_translate_option ( $recipient->lang, 'alo_em_custom_viewonline_msg', true );
$viewonline_url = alo_em_translate_url ( $recipient->newsletter /*get_permalink( $recipient->newsletter )*/, $recipient->lang );
$trackable_viewonline_url = alo_em_make_url_trackable ( $recipient, $viewonline_url );
if( empty( $viewonline_msg ) )
{
$viewonline_msg = __('To read the newsletter online you can visit this link:', 'alo-easymail') . ' %NEWSLETTERLINK%';
}
$viewonline_msg = str_replace( '%NEWSLETTERLINK%', ' '. $subject /*$viewonline_url*/ .'', $viewonline_msg );
$viewonline_msg = str_replace( '%NEWSLETTERURL%', $trackable_viewonline_url /*$viewonline_url*/, $viewonline_msg );
}
$unsubfooter = $uns_link = $tracking_view = ""; // default empty
if ( isset( $recipient->unikey ) ) { // if subscriber
$uns_vars = $recipient->subscriber . '|' . $recipient->unikey;
$uns_vars = urlencode( base64_encode( $uns_vars ) );
$uns_link = add_query_arg( 'emunsub', $uns_vars, alo_em_translate_home_url ( $recipient->lang ) /*trailingslashit( get_home_url() )*/ );
//$uns_link = alo_em_translate_url ( $uns_link, $recipient->lang );
$unsubfooter = alo_em_translate_option ( $recipient->lang, 'alo_em_custom_unsub_footer', true );
if ( empty( $unsubfooter ) )
{
$unsubfooter = __('You have received this message because you subscribed to our newsletter. If you want to unsubscribe: ', 'alo-easymail').' %UNSUBSCRIBELINK%';
}
$unsubfooter = str_replace ( '%UNSUBSCRIBELINK%', ' '. $uns_link/*__('visit this link', 'alo-easymail')*/ .'', $unsubfooter );
$unsubfooter = str_replace ( '%UNSUBSCRIBEURL%', $uns_link, $unsubfooter );
// Tracking code
if ( get_option('alo_em_use_tracking_pixel') != "no" ) {
$track_vars = $recipient->ID . '|' . $recipient->unikey;
$track_vars = urlencode( base64_encode( $track_vars ) );
$tracking_url = rest_url( 'alo-easymail/v1/trkpxl' );
$tracking_url = add_query_arg( array(
'empxltrk' => $track_vars,
'lang' => $recipient->lang,
), $tracking_url );
$tracking_view = '';
} else {
$tracking_view = '';
}
}
// Content default if not theme found
$html = $content;
// Get the theme file
$default_theme = get_option('alo_em_use_themes');
if ( $default_theme != 'no' ) {
if ( $default_theme == "yes" ) { // Free choice
$theme = get_post_meta ( $newsletter->ID, '_easymail_theme', true );
} else { // Force theme by option
$theme = $default_theme;
}
if ( $theme != "" && array_key_exists( $theme, alo_easymail_get_all_themes() ) ) {
$themes = alo_easymail_get_all_themes();
$theme_path = ( isset( $themes[$theme] ) && file_exists( $themes[$theme] ) ) ? $themes[$theme] : false;
if ( $theme_path ) {
//$html = file_get_contents( $theme_path ); // replaced by eqhes, for php themes
ob_start();
require( $theme_path );
$html = ob_get_clean();
$html = alo_em_translate_text ( $recipient->lang, $html ); // translate the text ih html theme
$html = str_replace('[CONTENT]', $content, $html);
$info = pathinfo( $theme );
$theme_dir = basename( $theme, '.' . $info['extension'] );
//$html = str_replace( $theme_dir, alo_easymail_get_themes_url().$theme_dir, $html );
$html = preg_replace( '/ src\=[\'|"]'. $theme_dir.'(.+?)[\'|"]/', ' src="'. alo_easymail_get_themes_url().$theme_dir. '$1"', $html ); //
$html = preg_replace( '/url(.+?)[\s|\'|"]'. $theme_dir.'(.+?)[\s|\'|"]/', "url('". alo_easymail_get_themes_url() .$theme_dir. "$2'", $html ); // in style: url("...")
$html = preg_replace( '/ background\=[\'|"]'. $theme_dir.'(.+?)[\'|"]/', ' background="'. alo_easymail_get_themes_url().$theme_dir. '$1"', $html ); //