» Please visit plugin site for more info and feedback: www.eventualo.net
» If you use this plugin consider the idea of donating and supporting its development:
"); define("ALO_EM_INTERVAL_MIN", 10); // cron interval in minutes (default: 10) (NOTE: to apply the change you need to reactivate the plugin) define("ALO_EM_PLUGIN_DIR", basename(dirname(__FILE__)) ); define("ALO_EM_PLUGIN_URL", WP_PLUGIN_URL ."/" . ALO_EM_PLUGIN_DIR ); /** * Required functions */ require_once( 'alo-easymail_functions.php'); /** * On plugin activation */ function ALO_em_install() { global $wpdb, $wp_roles; if (!get_option('ALO_em_template')) add_option('ALO_em_template', 'Hi [USER-NAME],| \n"; $html .= " | \n"; $html .= " \n"; $html .= " | \n"; $html .= "
|---|
';
} else {
echo "#".($row_count - 1);
}
echo " " . stripslashes ( ALO_em___( $q->subject ) ) ."". __("There are no newsletters in queue", "alo-easymail") . ".
"; } echo "". sprintf( __("There are %d subscribers: %d activated, %d not activated", "alo-easymail"), $total, $active, $noactive ) . ".
"; } else { echo "". __("No subscribers", "alo-easymail") . ".
"; } } function ALO_em_add_dashboard_widgets() { if ( current_user_can ( 'manage_easymail_subscribers' ) && current_user_can ( 'manage_easymail_newsletters' ) ) { wp_add_dashboard_widget('alo-easymail-widget', 'EasyMail Newsletter', 'ALO_em_dashboard_widget_function'); } } add_action('wp_dashboard_setup', 'ALO_em_add_dashboard_widgets' ); /** * SHOW the optin/optout on registration form */ function ALO_em_show_registration_optin () { $optin_txt = ( ALO_em_translate_option ( ALO_em_get_language (), 'ALO_em_custom_optin_msg', false) !="") ? ALO_em_translate_option ( ALO_em_get_language (), 'ALO_em_custom_optin_msg', false) : __("Yes, I would like to receive the Newsletter", "alo-easymail"); echo ''; echo '
'; $mailinglists = ALO_em_get_mailinglists( 'public' ); if ( $mailinglists ) { $lists_msg = ( ALO_em_translate_option ( ALO_em_get_language (), 'ALO_em_custom_lists_msg',false) !="") ? ALO_em_translate_option ( ALO_em_get_language (), 'ALO_em_custom_lists_msg',false) : __("You can also sign up for specific lists", "alo-easymail"); echo "". $lists_msg .":
\n"; foreach ( $mailinglists as $list => $val ) { echo "\n"; } } echo ' '; } add_action('register_form','ALO_em_show_registration_optin'); /** * SAVE the optin/optout on registration form */ function ALO_em_save_registration_optin ($user_id, $password="", $meta=array()) { $user = get_userdata($user_id); if (!empty($user->first_name) && !empty($user->last_name)) { $name = $user->first_name.' '.$user->last_name; } else { $name = $user->display_name; } if ( isset ($_POST['alo_em_opt']) && $_POST['alo_em_opt'] == "yes" ) { $lang = ( isset($_POST['alo_em_lang']) && in_array ( $_POST['alo_em_lang'], ALO_em_get_all_languages( false )) ) ? $_POST['alo_em_lang'] : "" ; ALO_em_add_subscriber( $user->user_email, $name , 1, $lang ); // if subscribing, save also lists $mailinglists = ALO_em_get_mailinglists( 'public' ); if ($mailinglists) { $subscriber_id = ALO_em_is_subscriber( $user->user_email ); foreach ( $mailinglists as $mailinglist => $val) { if ( isset ($_POST['alo_em_register_lists']) && is_array ($_POST['alo_em_register_lists']) && in_array ( $mailinglist, $_POST['alo_em_register_lists'] ) ) { ALO_em_add_subscriber_to_list ( $subscriber_id, $mailinglist ); // add to list } } } } } add_action( 'user_register', 'ALO_em_save_registration_optin' ); /** EXPERIMENTAL * Return the localised login url */ /* function ALO_em_login_url( $url ) { // qTranslate if( ALO_em_multilang_enabled_plugin() == "qTrans") $url = add_query_arg( 'lang', ALO_em_get_language(), $url ); return $url; } add_filter( 'login_url', 'ALO_em_login_url', 10); */ /** EXPERIMENTAL * Return the localised register url */ /* function ALO_em_register_url( $url ) { // qTranslate //if( ALO_em_multilang_enabled_plugin() == "qTrans") $url = add_query_arg( 'lang', ALO_em_get_language(), $url ); return $url; } add_filter( 'register', 'ALO_em_register_url', 10 ); */ /** * Edit the e-mail message */ function ALO_em_handle_email ( $args ) { // $args['to'], $args['subject'], $args['message'], $args['headers'], $args['attachments'] // Check based on $args['subject']; more attrs in $args['message'] global $_config; /* * 1) Activation e-mail */ if ( strpos ( "#_EASYMAIL_ACTIVATION_#", $args['subject'] ) !== false) { // Get the parameters stored as a query in $args['message'] $defaults = array( 'lang' => '', 'email' => '', 'name' => '', 'unikey' => '' ); $customs = wp_parse_args( $args['message'], $defaults ); extract( $customs, EXTR_SKIP ); // Subject if ( ALO_em_translate_option ( $lang, 'ALO_em_txtpre_activationmail_subj', false ) ) { $subject = ALO_em_translate_option ( $lang, 'ALO_em_txtpre_activationmail_subj', false ); } else { $subject = ALO_em___( __("Confirm your subscription to %BLOGNAME% Newsletter", "alo-easymail" ) ); } $blogname = html_entity_decode ( wp_kses_decode_entities ( get_option('blogname') ) ); $subject = str_replace ( "%BLOGNAME%", $blogname, $subject ); $args['subject'] = $subject; // Content if ( ALO_em_translate_option ( $lang, 'ALO_em_txtpre_activationmail_mail', false ) ) { $content = ALO_em_translate_option ( $lang, 'ALO_em_txtpre_activationmail_mail', false ); } else { $content = __("Hi %NAME%\nto complete your subscription to %BLOGNAME% newsletter you need to click on the following link (or paste it in the address bar of your browser):\n", "alo-easymail"); $content .= "%ACTIVATIONLINK%\n\n"; $content .= __("If you did not ask for this subscription ignore this message.", "alo-easymail"). "\n"; $content .= __("Thank you", "alo-easymail")."\n". $blogname ."\n"; } $div_email = explode("@", $email); $arr_params = array ('ac' => 'activate', 'em1' => $div_email[0], 'em2' => $div_email[1], 'uk' => $unikey ); $sub_link = add_query_arg( $arr_params, get_page_link (get_option('ALO_em_subsc_page')) ); $sub_link = ALO_em_translate_url ( $sub_link, $lang ); $content = str_replace ( "%BLOGNAME%", $blogname, $content ); $content = str_replace ( "%NAME%", $name, $content ); $content = str_replace ( "%ACTIVATIONLINK%", $sub_link, $content ); $args['message'] = $content; } return $args; } add_filter('wp_mail', 'ALO_em_handle_email'); ?>