/** * Box meta: Recipients */ function alo_em_meta_recipients($post) { wp_nonce_field(ALO_EM_PLUGIN_DIR, "edit_newsletter"); //print_r ( alo_em_get_recipients_from_meta($post->ID) ); print_r ( alo_em_get_all_languages() ); echo "<p " . (alo_em_count_recipients_from_meta($post->ID) == 0 ? "class=\"easymail-txtwarning\"" : "") . " >"; echo "<strong>" . __("Selected recipients", "alo-easymail") . ": " . alo_em_count_recipients_from_meta($post->ID) . "</strong></p>"; if (alo_em_get_newsletter_status($post->ID) == "sent" || alo_em_is_newsletter_recipients_archived($post->ID)) { echo "<div class=\"easymail-alert\"><p>" . __("This newsletter was already sent", "alo-easymail") . ".</p>"; echo "</div>"; return; // exit } if (alo_em_count_newsletter_recipients($post->ID) > 0) { echo "<div class=\"easymail-alert\"><p>" . __("The creation of the recipients list has already started", "alo-easymail") . ".</p>"; echo "<p><input type=\"checkbox\" name=\"easymail-reset-all-recipients\" id=\"easymail-reset-all-recipients\" value=\"yes\" /> "; echo "<strong><label for=\"easymail-reset-all-recipients\">" . __("Check this flag to delete the existing list and save new recipients now", "alo-easymail") . ".</label></strong></p>"; echo "</div>"; } $recipients = alo_em_get_recipients_from_meta($post->ID); ?> <div class="easymail-edit-recipients easymail-edit-recipients-registered"> <ul class="level-1st"> <li class="list-title"><?php _e("Users"); ?> :</li> <li> <?php $checked = isset($recipients['registered']) ? ' checked="checked" ' : ''; ?> <label for="easymail-recipients-all-regusers" class="easymail-metabox-update-count"><?php echo __("All registered users", "alo-easymail"); ?> </label> <input type="checkbox" name="easymail-recipients-all-regusers" id="easymail-recipients-all-regusers" value="checked" <?php echo $checked; ?> class="easymail-metabox-update-count" /> </li> <?php // Roles global $wp_roles; $roles = $wp_roles->get_names(); // get a list of values, containing pairs of: $role_name => $display_name if ($roles) { ?> <li><a href="#" class="easymail-filter-regusers-by-roles"><?php _e("Filter users according to roles", "alo-easymail"); ?> ...</a></li> <li> <ul id="easymail-filter-ul-roles" class="level-2st"> <?php foreach ($roles as $key => $label) { $checked = isset($recipients['role']) && in_array($key, $recipients['role']) ? ' checked="checked" ' : ''; ?> <li> <label for="role_<?php echo $key; ?> " class="easymail-metabox-update-count"><?php echo translate_user_role($label); ?> </label> <input type="checkbox" name="check_role[]" class="check_role easymail-metabox-update-count" id="role_<?php echo $key; ?> " value="<?php echo $key; ?> " <?php echo $checked; ?> /> </li> <?php } ?> </ul> </li> <?php } // roles ?> </ul> </div><!-- /easymail-edit-recipients-registered --> <div class="easymail-edit-recipients easymail-edit-recipients-subscribers"> <ul class="level-1st"> <li class="list-title"><?php _e("Newsletter subscribers", "alo-easymail"); ?> :</li> <li> <?php $checked = isset($recipients['subscribers']) ? ' checked="checked" ' : ''; ?> <label for="easymail-recipients-all-subscribers" class="easymail-metabox-update-count"><?php echo __("All subscribers", "alo-easymail"); ?> </label> <input type="checkbox" name="easymail-recipients-all-subscribers" id="easymail-recipients-all-subscribers" value="checked" <?php echo $checked; ?> class="easymail-metabox-update-count" /> </li> <?php // if mailing lists $mailinglists = alo_em_get_mailinglists('admin,public'); if ($mailinglists) { ?> <li><a href="#" class="easymail-filter-subscribers-by-lists"><?php _e("Filter subscribers according to lists", "alo-easymail"); ?> ...</a></li> <li> <ul id="easymail-filter-ul-lists" class="level-2st"> <?php foreach ($mailinglists as $list => $val) { if ($val['available'] == "deleted" || $val['available'] == "hidden") { continue; } $checked = isset($recipients['list']) && in_array($list, $recipients['list']) ? ' checked="checked" ' : ''; ?> <li> <label for="list_<?php echo $list; ?> " class="easymail-metabox-update-count"><?php echo alo_em_translate_multilangs_array(alo_em_get_language(), $val['name'], true); ?> </label> <input type="checkbox" name="check_list[]" class="check_list easymail-metabox-update-count" id="list_<?php echo $list; ?> " value="<?php echo $list; ?> " <?php echo $checked; ?> /> </li> <?php } ?> </ul> </li> <?php } // $mailinglists ?> <?php // if languages $languages = alo_em_get_all_languages(false); if ($languages) { ?> <li><a href="#" class="easymail-filter-subscribers-by-languages"><?php _e("Filter subscribers according to languages", "alo-easymail"); ?> ...</a></li> <li> <ul id="easymail-filter-ul-languages" class="level-2st"> <?php foreach ($languages as $index => $lang) { $checked = isset($recipients['lang']) && in_array($lang, $recipients['lang']) || !isset($recipients['lang']) ? ' checked="checked" ' : ''; $tot_sub_x_lang = alo_em_count_subscribers_by_lang($lang, true); ?> <li> <label for="check_lang_<?php echo $lang; ?> " class="easymail-metabox-update-count" > <?php echo esc_html(alo_em_get_lang_name($lang)); ?> </label> <input type="checkbox" name="check_lang[]" class="check_lang easymail-metabox-update-count" id="check_lang_<?php echo $lang; ?> " value="<?php echo $lang; ?> " <?php echo $checked; ?> /> </li> <?php } $checked = isset($recipients['lang']) && in_array("UNKNOWN", $recipients['lang']) || !isset($recipients['lang']) ? ' checked="checked" ' : ''; ?> <li> <label for="check_lang_unknown" class="easymail-metabox-update-count"> <?php _e("Not specified / others", "alo-easymail"); ?> <?php /*echo ' ('. alo_em_count_subscribers_by_lang(false, true).')';*/ ?> </label> <input type="checkbox" name="check_lang[]" class="check_lang easymail-metabox-update-count" id="check_lang_unknown" value="UNKNOWN" <?php echo $checked; ?> /> </li> </ul> </li> <?php } // $languages ?> </ul> </div><!-- /easymail-edit-recipients-subscribers --> <?php }
:<br />[READ-ONLINE]</th> <td><span class="description"><?php _e("Leave blank to use default text", "alo-easymail"); ?> :</span><br /> <?php echo "<p><em>" . __("To read the newsletter online you can visit this link:", "alo-easymail") . " %NEWSLETTERLINK% </em></p>"; ?> <div id="viewonline_msg_container"> <?php $custom_texts = get_option('alo_em_custom_viewonline_msg'); if ($languages) { $lang_li = array(); $lang_div = array(); foreach ($languages as $key => $lang) { $lang_li[$lang] = '<li><a href="#viewonline_msg_div_' . $lang . '"><strong>' . alo_em_get_lang_name($lang) . '</strong></a></li>'; $lang_div[$lang] = '<div id ="viewonline_msg_div_' . $lang . '">'; $lang_text = !empty($custom_texts[$lang]) ? esc_html($custom_texts[$lang]) : ""; $lang_div[$lang] .= '<textarea name="viewonline_msg_' . $lang . '" rows="3" style="width:100%" />' . $lang_text . '</textarea>'; $lang_div[$lang] .= '</div>'; } } ?> <ul id="viewonline_msg_tabs"> <?php echo implode("\n\n", $lang_li); ?> </ul> <?php echo implode("\n\n", $lang_div);
/** * Html row of a Subscriber in subscriber table */ function alo_em_get_subscriber_table_row($subscriber_id, $row_index = 0, $edit = false, $all_lists = false, $all_langs = false) { if (empty($subscriber_id)) { return false; } $subscriber = alo_em_get_subscriber_by_id($subscriber_id); $html = ""; //$html .= "<tr id=\"subscriber-row-{$subscriber_id}\" class=\"subscriber-row\">\n"; $html .= "<th scope=\"row\" class=\"subscriber-row-index\">" . $row_index . "</th>\n"; $html .= "<td style=\"vertical-align: middle;\">"; $html .= "<input type=\"checkbox\" name=\"subscribers[]\" id=\"subscribers_" . $subscriber_id . "\" value=\"" . $subscriber_id . "\" />\n"; $html .= "</td>\n"; if (get_option('show_avatars')) { $html .= "<td>" . get_avatar($subscriber->email, 30) . " </td>"; } $html .= "<td class=\"subscriber-email\">"; if ($edit) { $html .= "<input type=\"text\" id=\"subscriber-" . $subscriber_id . "-email-new\" name=\"subscriber-" . $subscriber_id . "-email-new\" class=\"subscriber-email-new\" value=\"" . format_to_edit($subscriber->email) . "\" />\n"; } else { $html .= esc_html($subscriber->email); } $html .= " </td>\n"; $html .= "<td class=\"subscriber-name\">"; if ($edit) { $html .= "<input type=\"text\" id=\"subscriber-" . $subscriber_id . "-name-new\" name=\"subscriber-" . $subscriber_id . "-name-new\" class=\"subscriber-name-new\" value=\"" . format_to_edit($subscriber->name) . "\" />\n"; } else { $html .= esc_html($subscriber->name); } $html .= " </td>\n"; //edit : added the following foreach and its content $alo_em_cf = alo_easymail_get_custom_fields(); if ($alo_em_cf) { foreach ($alo_em_cf as $key => $value) { $field_id = "subscriber-" . $subscriber_id . "-" . $key . "-new"; // edit-by-alo: added $html .= "<td class=\"subscriber-" . $key . "-new\">"; // edit-by-alo if ($edit) { $var_value = ""; if (!empty($subscriber->{$key})) { $var_value = $subscriber->{$key}; } // edit-by-alo: added //$html .= sprintf( $value['edit_html'], $subscriber_id, $subscriber_id, format_to_edit( $var_value ) ); $html .= alo_easymail_custom_field_html($key, $value, $field_id, $var_value, true); } else { $var_value = ""; // particular case: empty is a negative checkbox if (empty($subscriber->{$key}) && $value['input_type'] == 'checkbox') { $html .= alo_easymail_custom_field_html($key, $value, $field_id, $var_value, false); } else { if (!empty($subscriber->{$key})) { $var_value = $subscriber->{$key}; $html .= alo_easymail_custom_field_html($key, $value, $field_id, $var_value, false); } else { $html .= ""; } } } $html .= " </td>\n"; } } $html .= "<td>"; $user_id = email_exists($subscriber->email); if (!$user_id) { $user_id = apply_filters('alo_easymail_get_userid_by_subscriber', false, $subscriber); // Hook } if ($user_id) { $user_info = get_userdata($user_id); if (get_current_user_id() == $user_id) { $profile_link = 'profile.php'; } else { $profile_link = esc_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), "user-edit.php?user_id={$user_id}")); } $html .= "<a href=\"" . $profile_link . "\" title=\"" . esc_attr(__("View user profile", "alo-easymail")) . "\">{$user_info->user_login}</a>"; } $html .= " </td>\n"; $html .= "<td class=\"subscriber-joindate\">\n"; $join_date_datetime = date_i18n(__("d/m/Y \\h.H:i", "alo-easymail"), strtotime($subscriber->join_date)); $join_time_diff = sprintf(__("%s ago", "alo-easymail"), human_time_diff(strtotime($subscriber->join_date), current_time('timestamp'))); //$html .= $join_time_diff ." <img src=\"".ALO_EM_PLUGIN_URL."/images/12-clock.png\" class=\"clock\" title=\"". esc_attr($join_date_datetime) ."\" alt=\"". $join_date_datetime ."\" />\n"; $html .= "<abbr title=\"" . esc_attr($join_date_datetime) . "\" />" . $join_time_diff . "</abbr>\n"; $html .= "</td>\n"; $html .= "<td class=\"subscriber-lastact\">\n"; $last_act = !empty($subscriber->last_act) ? $subscriber->last_act : $subscriber->join_date; $last_act_datetime = date_i18n(__("d/m/Y \\h.H:i", "alo-easymail"), strtotime($last_act)); $last_act_diff = sprintf(__("%s ago", "alo-easymail"), human_time_diff(strtotime($last_act), current_time('timestamp'))); //$last_ip_addr = ' @ IP: '. ( !empty($subscriber->ip_address) ? $subscriber->ip_address : '?' ); //$html .= $last_act_diff ." <img src=\"".ALO_EM_PLUGIN_URL."/images/12-clock.png\" class=\"clock\" title=\"". esc_attr($last_act_datetime . $last_ip_addr) ."\" alt=\"(". $last_act_datetime .")\" />\n"; $html .= "<abbr title=\"" . esc_attr($last_act_datetime) . "\" />" . $last_act_diff . "</abbr>\n"; if (!empty($subscriber->ip_address)) { $last_ip_addr = preg_replace('/[^0-9a-fA-F:., ]/', '', $subscriber->ip_address); $html .= "<br /><a href=\"http://www.whatismyipaddress.com/ip/{$last_ip_addr}\" title=\"" . esc_attr($last_ip_addr . ' @ whatismyipaddress.com') . "\" target=\"_blank\" class=\"ip-address\"/>IP " . $last_ip_addr . "</abbr>\n"; } $html .= "</td>\n"; $html .= "<td class=\"subscriber-active\">\n"; if ($edit) { $active_checked = $subscriber->active == 1 ? " checked=\"checked\" " : ""; $html .= "<input type=\"checkbox\" id=\"subscriber-" . $subscriber_id . "-active-new\" name=\"subscriber-" . $subscriber_id . "-active-new\" class=\"subscriber-active-new\" {$active_checked} />\n"; } else { $html .= "<img src=\"" . ALO_EM_PLUGIN_URL . "/images/" . ($subscriber->active == 1 ? "yes.png" : "no.png") . "\" />\n"; } $html .= "</td>\n"; $html .= "<td class=\"subscriber-lists\">\n"; $user_lists = alo_em_get_user_mailinglists($subscriber_id); if ($edit && is_array($all_lists)) { foreach ($all_lists as $list => $val) { $checked = is_array($user_lists) && in_array($list, $user_lists) ? " checked=\"checked\" " : ""; $html .= "<input type=\"checkbox\" name=\"subscriber-" . $subscriber_id . "-lists-new[]\" class=\"subscriber-lists-new subscriber-" . $subscriber_id . "-lists-new\" id=\"subscriber-" . $subscriber_id . "-lists-new_" . $list . "\" value=\"" . $list . "\" {$checked} /><label for=\"subscriber-" . $subscriber_id . "-lists-new_" . $list . "\">" . alo_em_translate_multilangs_array(alo_em_get_language(), $val['name'], true) . "</label><br />\n"; } } else { if ($user_lists && is_array($user_lists) && $all_lists) { $html .= "<ul class=\"userlists\">\n"; foreach ($user_lists as $user_list) { $html .= "<li>" . alo_em_translate_multilangs_array(alo_em_get_language(), $all_lists[$user_list]["name"], true) . "</li>\n"; } $html .= "</ul>\n"; } } $html .= " </td>\n"; $html .= "<td class=\"subscriber-lang\">\n"; if ($edit && is_array($all_langs) && !empty($all_langs[0])) { $html .= "<select id=\"subscriber-" . $subscriber_id . "-lang-new\" name=\"subscriber-" . $subscriber_id . "-lang-new\">\n"; $html .= "<option value=\"\"></option>\n"; foreach ($all_langs as $key => $val) { $selected = $subscriber->lang == $val ? " selected=\"selected\" " : ""; $lang_name = esc_html(alo_em_get_lang_name($val)); $html .= "<option value=\"" . $val . "\" " . $selected . ">" . $lang_name . "</option>\n"; } $html .= "</select>\n"; } else { $html .= $subscriber->lang ? alo_em_get_lang_flag($subscriber->lang, 'name') : ""; } $html .= " </td>\n"; $html .= "<td class=\"subscriber-actions\">\n"; // Actions $html .= "<img src=\"" . ALO_EM_PLUGIN_URL . "/images/wpspin_light.gif\" style=\"display:none;vertical-align: middle;\" id=\"easymail-subscriber-" . $subscriber_id . "-actions-loading\" />\n"; if ($edit) { $html .= " <a href=\"\" title=\"" . esc_attr(__("Cancel", "alo-easymail")) . "\" class=\"easymail-subscriber-edit-inline-cancel\" id=\"easymail-subscriber-edit-inline-cancel_{$subscriber_id}\" rel=\"{$subscriber_id}\">"; $html .= "<img src=\"" . ALO_EM_PLUGIN_URL . "/images/no.png\" /></a>\n"; $html .= " <a href=\"\" title=\"" . esc_attr(__("Save", "alo-easymail")) . "\" class=\"easymail-subscriber-edit-inline-save\" id=\"easymail-subscriber-edit-inline-save_{$subscriber_id}\" rel=\"{$subscriber_id}\">"; $html .= "<img src=\"" . ALO_EM_PLUGIN_URL . "/images/yes.png\" /></a>\n"; } else { $html .= "<a href=\"\" title=\"" . esc_attr(__("Quick edit", "alo-easymail")) . "\" class=\"easymail-subscriber-edit-inline\" id=\"easymail-subscriber-edit-inline_{$subscriber_id}\" rel=\"{$subscriber_id}\">"; $html .= "<img src=\"" . ALO_EM_PLUGIN_URL . "/images/16-edit.png\" alt=\"" . esc_attr(__("Quick edit", "alo-easymail")) . "\" /></a>"; $html .= " <a href=\"\" title=\"" . esc_attr(__("Delete subscriber", "alo-easymail")) . "\" class=\"easymail-subscriber-delete\" id=\"easymail-subscriber-delete_{$subscriber_id}\" rel=\"{$subscriber_id}\">"; $html .= "<img src=\"" . ALO_EM_PLUGIN_URL . "/images/trash.png\" alt=\"" . esc_attr(__("Delete subscriber", "alo-easymail")) . "\" /></a>"; $html .= " <a href=\"\" title=\"" . esc_attr(__("Delete subscriber and add the email to the list of who unsubscribed", "alo-easymail")) . "\" class=\"easymail-subscriber-delete and-unsubscribe\" id=\"easymail-subscriber-delete-and-unsubscribe_{$subscriber_id}\" rel=\"{$subscriber_id}\">"; $html .= "<img src=\"" . ALO_EM_PLUGIN_URL . "/images/trash_del.png\" alt=\"" . esc_attr(__("Delete subscriber and add the email to the list of who unsubscribed", "alo-easymail")) . "\" /></a>"; } $html .= "</td>\n"; return $html; }