function newsletter_save($subscriber) { global $wpdb; $email = newsletter_normalize_email($email); $name = newsletter_normalize_name($name); $wpdb->query($wpdb->prepare("update " . $wpdb->prefix . "newsletter set email=%s, name=%s where id=%d", $subscriber['email'], $subscriber['name'], $subscriber['id'])); }
$errors = array(); foreach ($lines as $line) { $line = trim($line); if ($line == '') { continue; } if ($line[0] == '#') { continue; } $data = explode(';', $line); $email = newsletter_normalize_email($data[0]); if (!newsletter_is_email($email)) { $errors[] = $line; continue; } $name = newsletter_normalize_name($data[1]); $token = md5(rand()); $r = $wpdb->query("insert into " . $wpdb->prefix . "newsletter (status, email, name, token) values ('C', '" . $wpdb->escape($email) . "','" . $wpdb->escape($name) . "','" . $token . "')"); // Zero or false mean no row inserted if (!$r) { $errors[] = $line; } } } $nc = new NewsletterControls(); ?> <div class="wrap"> <h2><?php _e('Newsletter Import', 'newsletter');