adding initial version
git-svn-id: https://plugins.svn.wordpress.org/send-email-from-admin/trunk@1275705 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
parent
199c0e5cac
commit
211ab12615
40
css/sefa.css
Normal file
40
css/sefa.css
Normal file
@ -0,0 +1,40 @@
|
||||
#sefa-wrapper {
|
||||
width: 70%;
|
||||
}
|
||||
#sefa-wrapper h1 {
|
||||
font-weight: 400;
|
||||
padding-top: 10px;
|
||||
}
|
||||
#sefa-wrapper div.error,
|
||||
#sefa-wrapper div.updated {
|
||||
margin: 0;
|
||||
padding: 10px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
#sefa-form td {
|
||||
vertical-align: text-top;
|
||||
padding: 10px;
|
||||
}
|
||||
#sefa-form input[type=text],
|
||||
#sefa-form input[type=email],
|
||||
#sefa-form textarea,
|
||||
#sefa-form .wp-editor-wrap {
|
||||
width: 100%;
|
||||
padding: 10px
|
||||
}
|
||||
#sefa-form .wp-editor-wrap {
|
||||
padding-left: 0;
|
||||
}
|
||||
#sefa-form #sefa-user-list {
|
||||
margin-top: 6px;
|
||||
}
|
||||
#sefa-form .note {
|
||||
font-size: 11px;
|
||||
padding: 5px 0 0 1px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1200px) {
|
||||
#sefa-wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
11
js/sefa.js
Normal file
11
js/sefa.js
Normal file
@ -0,0 +1,11 @@
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
$("#sefa-user-list").change( function() {
|
||||
$recipients = $("#sefa-recipient-emails");
|
||||
if ( $recipients.val() == '' ) {
|
||||
$recipients.val( $(this).find("option:selected").attr("value") );
|
||||
} else if ( $(this).val() != '' ) {
|
||||
$recipients.val( $recipients.val() + ',' + $(this).find("option:selected").attr("value") );
|
||||
}
|
||||
$(this).find("option:selected").attr("disabled","disabled");
|
||||
})
|
||||
} );
|
||||
BIN
languages/sefa-fr_FR.mo
Normal file
BIN
languages/sefa-fr_FR.mo
Normal file
Binary file not shown.
74
languages/sefa-fr_FR.po
Normal file
74
languages/sefa-fr_FR.po
Normal file
@ -0,0 +1,74 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Simple Email From Admin\n"
|
||||
"POT-Creation-Date: 2015-10-28 13:05-0330\n"
|
||||
"PO-Revision-Date: 2015-10-28 13:05-0330\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.5.7\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_;gettext;gettext_noop\n"
|
||||
"X-Poedit-Basepath: ../\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: simple-email-from-admin.php:73
|
||||
msgid "Please enter an email recipient in the To: field."
|
||||
msgstr "S'il vous plaît entrer une adresse e-mail dans le champ A:."
|
||||
|
||||
#: simple-email-from-admin.php:87
|
||||
msgid "Please enter a Subject."
|
||||
msgstr "S'il vous plaît entrer un sujet."
|
||||
|
||||
#: simple-email-from-admin.php:88
|
||||
msgid "Please enter a Message."
|
||||
msgstr "S'il vous plaît entrer un message."
|
||||
|
||||
#: simple-email-from-admin.php:98
|
||||
msgid "Your email has been successfully sent!"
|
||||
msgstr "Votre e-mail a été envoyé avec succès!"
|
||||
|
||||
#: simple-email-from-admin.php:100
|
||||
msgid "There was an error sending the email."
|
||||
msgstr "Il y avait une erreur d'envoi du courriel."
|
||||
|
||||
#: simple-email-from-admin.php:105
|
||||
msgid "Your email has been successfully sent to "
|
||||
msgstr "Votre courriel a été envoyé avec succès à "
|
||||
|
||||
#: simple-email-from-admin.php:107
|
||||
msgid "There was an error sending the email to "
|
||||
msgstr "Il y avait une erreur d'envoi de l'e-mail "
|
||||
|
||||
#: simple-email-from-admin.php:115
|
||||
msgid "Send Email From Admin"
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:138
|
||||
msgid "These can be changed in Settings->General."
|
||||
msgstr "Ceux-ci peuvent être modifiés en Settings->General."
|
||||
|
||||
#: simple-email-from-admin.php:142
|
||||
msgid ""
|
||||
"To send to multiple recipeints, enter each email address seperated by a "
|
||||
"comma or choose from the user list below."
|
||||
msgstr ""
|
||||
"Pour envoyer à plusieurs destinataires, entrez chaque adresse mail séparée "
|
||||
"par une virgule ou choisir parmi la liste des utilisateurs ci-dessous."
|
||||
|
||||
#: simple-email-from-admin.php:144
|
||||
msgid "user list"
|
||||
msgstr "la liste des utilisateurs"
|
||||
|
||||
#: simple-email-from-admin.php:163
|
||||
msgid "Send each recipient an individual email"
|
||||
msgstr "Envoyer un e-mail chaque destinataire individuel"
|
||||
|
||||
#: simple-email-from-admin.php:166
|
||||
msgid "Send a group email to all recipients"
|
||||
msgstr "Envoyer un e-mail de groupe à tous les destinataires"
|
||||
|
||||
#: simple-email-from-admin.php:188
|
||||
msgid "Send Message"
|
||||
msgstr "Envoyer le message"
|
||||
72
languages/sefa.pot
Normal file
72
languages/sefa.pot
Normal file
@ -0,0 +1,72 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Simple Email From Admin\n"
|
||||
"POT-Creation-Date: 2015-10-28 13:01-0330\n"
|
||||
"PO-Revision-Date: 2015-10-28 13:01-0330\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.5.7\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_;gettext;gettext_noop\n"
|
||||
"X-Poedit-Basepath: ../\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: simple-email-from-admin.php:73
|
||||
msgid "Please enter an email recipient in the To: field."
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:87
|
||||
msgid "Please enter a Subject."
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:88
|
||||
msgid "Please enter a Message."
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:98
|
||||
msgid "Your email has been successfully sent!"
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:100
|
||||
msgid "There was an error sending the email."
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:105
|
||||
msgid "Your email has been successfully sent to "
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:107
|
||||
msgid "There was an error sending the email to "
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:115
|
||||
msgid "Send Email From Admin"
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:138
|
||||
msgid "These can be changed in Settings->General."
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:142
|
||||
msgid ""
|
||||
"To send to multiple recipeints, enter each email address seperated by a "
|
||||
"comma or choose from the user list below."
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:144
|
||||
msgid "user list"
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:163
|
||||
msgid "Send each recipient an individual email"
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:166
|
||||
msgid "Send a group email to all recipients"
|
||||
msgstr ""
|
||||
|
||||
#: simple-email-from-admin.php:188
|
||||
msgid "Send Message"
|
||||
msgstr ""
|
||||
47
readme.txt
Normal file
47
readme.txt
Normal file
@ -0,0 +1,47 @@
|
||||
=== Send Email From Admin ===
|
||||
Contributors: kojak711
|
||||
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8HHLL6WRX9Z68
|
||||
Tags: email, send email, admin email, custom email, email tools
|
||||
Requires at least: 4.0
|
||||
Tested up to: 4.3.1
|
||||
Stable tag: 0.9
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Easily send a simple custom email with an attachment from the WordPress administration screen.
|
||||
|
||||
== Description ==
|
||||
|
||||
Send Email From Admin gives you the ability to easily send a custom HTML email from the WordPress administration screen. You can send to existing users or add your own recipients. You can send to multiple recipients and choose to send group emails or individual emails. Emails can also have attachments. A new menu item called 'Send Email' is added under the Tools menu.
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Upload `send-email-from-admin` folder to the `/wp-content/plugins/` directory
|
||||
2. Activate the plugin through the 'Plugins' menu in WordPress
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Can I change the From name and From email address? =
|
||||
|
||||
Yes. The plugin uses the values that you entered for Site Title and E-Mail Address in Settings->General.
|
||||
|
||||
= Can I send to multiple recipients? =
|
||||
|
||||
Yes. You have the option to send to multiple recipents and you can choose to send the email as an individual email to each recipient (each recipient will only see their own email address in the To: field) or as a group email (each recipient will see the other recipients in the To: field).
|
||||
|
||||
= Can I add images to the email? =
|
||||
|
||||
Yes. You can add images from the WordPress Media Library.
|
||||
|
||||
= Can I add an attachment to the email? =
|
||||
|
||||
Yes. You can upload and attach one attachment to the email message.
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Send Email From Admin main screen.
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 0.9 =
|
||||
* Initial release
|
||||
243
send-email-from-admin.php
Normal file
243
send-email-from-admin.php
Normal file
@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Send Email From Admin
|
||||
Plugin URI:
|
||||
Description: Easily send a simple custom email with an attachment from the WordPress administration screen. Tools -> Send Email.
|
||||
Version: 0.9
|
||||
Author: kojak711
|
||||
Domain Path: /languages
|
||||
Text Domain: sefa
|
||||
|
||||
Send Email From Admin is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Send Email From Admin is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Send Email From Admin. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
# Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
define('SEFA_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ));
|
||||
|
||||
/**
|
||||
* Add our sub menu in the Tools menu
|
||||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
function sefa_plugin_admin_menu() {
|
||||
add_submenu_page( 'tools.php', 'Send Email From Admin', 'Send Email', 'manage_options', 'sefa_email', 'sefa_plugin_main' );
|
||||
}
|
||||
add_action( 'admin_menu', 'sefa_plugin_admin_menu' );
|
||||
|
||||
/**
|
||||
* Load our css and js.
|
||||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
function sefa_plugin_init() {
|
||||
wp_enqueue_style( 'sefa_admin_css', SEFA_PLUGIN_DIR_URL . '/css/sefa.css' );
|
||||
wp_enqueue_script( 'sefa_admin_js', SEFA_PLUGIN_DIR_URL . '/js/sefa.js', array('jquery'));
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', 'sefa_plugin_init' );
|
||||
|
||||
/**
|
||||
* Register our text domain.
|
||||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
function sefa_plugin_load_textdomain() {
|
||||
load_plugin_textdomain( 'sefa', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
|
||||
}
|
||||
add_action('plugins_loaded', 'sefa_plugin_load_textdomain');
|
||||
|
||||
/**
|
||||
* Our main function to display and
|
||||
* process our form
|
||||
* @since 0.9
|
||||
*/
|
||||
function sefa_plugin_main() {
|
||||
// get site info to construct 'FROM' for email
|
||||
$from_name = wp_specialchars_decode( get_option('blogname'), ENT_QUOTES );
|
||||
$from_email = get_bloginfo('admin_email');
|
||||
|
||||
// initialize
|
||||
$send_mail_message = false;
|
||||
|
||||
if ( !empty( $_POST ) && check_admin_referer( 'sefa_send_email', 'sefa-form-nonce' ) ) {
|
||||
// handle attachment
|
||||
$attachment_path = '';
|
||||
if ( $_FILES ) {
|
||||
if ( !function_exists( 'wp_handle_upload' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
}
|
||||
$uploaded_file = $_FILES['attachment'];
|
||||
$upload_overrides = array( 'test_form' => false );
|
||||
$attachment = wp_handle_upload( $uploaded_file, $upload_overrides );
|
||||
if ( $attachment && !isset( $attachment['error'] ) ) {
|
||||
// file was successfully uploaded
|
||||
$attachment_path = $attachment['file'];
|
||||
} else {
|
||||
// echo $attachment['error'];
|
||||
}
|
||||
}
|
||||
|
||||
// get the posted form values
|
||||
$sefa_recipient_emails = isset( $_POST['sefa_recipient_emails'] ) ? trim($_POST['sefa_recipient_emails']) : '';
|
||||
$sefa_subject = isset( $_POST['sefa_subject'] ) ? trim($_POST['sefa_subject']) : '';
|
||||
$sefa_body = isset( $_POST['sefa_body'] ) ? nl2br($_POST['sefa_body']) : '';
|
||||
$sefa_group_email = isset( $_POST['sefa_group_email'] ) ? trim($_POST['sefa_group_email']) : 'no';
|
||||
$recipients = explode( ',',$sefa_recipient_emails );
|
||||
|
||||
// initialize some vars
|
||||
$errors = array();
|
||||
$valid_email = true;
|
||||
|
||||
// simple form validation
|
||||
if ( empty( $sefa_recipient_emails ) ) {
|
||||
$errors[] = __( "Please enter an email recipient in the To: field.", 'sefa' );
|
||||
} else {
|
||||
// Loop through each email and validate it
|
||||
foreach( $recipients as $recipient ) {
|
||||
if ( !filter_var( trim($recipient), FILTER_VALIDATE_EMAIL ) ) {
|
||||
$valid_email = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// create appropriate error msg
|
||||
if ( !$valid_email ) {
|
||||
$errors[] = _n( "The To: email address appears to be invalid.", "One of the To: email addresses appears to be invalid.", count($recipients), 'sefa' );
|
||||
}
|
||||
}
|
||||
if ( empty($sefa_subject) ) $errors[] = __( "Please enter a Subject.", 'sefa' );
|
||||
if ( empty($sefa_body) ) $errors[] = __( "Please enter a Message.", 'sefa' );
|
||||
|
||||
// send the email if no errors were found
|
||||
if ( empty($errors) ) {
|
||||
$headers[] = "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
|
||||
$headers[] = 'From: ' . $from_name . ' <' . $from_email . ">\r\n";
|
||||
$attachments = $attachment_path;
|
||||
|
||||
if ( $sefa_group_email === 'yes' ) {
|
||||
if ( wp_mail( $sefa_recipient_emails, $sefa_subject, $sefa_body, $headers, $attachments ) ) {
|
||||
$send_mail_message = '<div class="updated">' . __( 'Your email has been successfully sent!', 'sefa' ) . '</div>';
|
||||
} else {
|
||||
$send_mail_message = '<div class="error">' . __( 'There was an error sending the email.', 'sefa' ) . '</div>';
|
||||
}
|
||||
} else {
|
||||
foreach( $recipients as $recipient ) {
|
||||
if ( wp_mail( $recipient, $sefa_subject, $sefa_body, $headers, $attachments ) ) {
|
||||
$send_mail_message .= '<div class="updated">' . __( 'Your email has been successfully sent to ', 'sefa' ) . esc_html($recipient) . '!</div>';
|
||||
} else {
|
||||
$send_mail_message .= '<div class="error">' . __( 'There was an error sending the email to ', 'sefa' ) . esc_html($recipient) . '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div id="sefa-wrapper">
|
||||
<h1><?php _e( 'Send Email From Admin', 'sefa' ); ?></h1>
|
||||
<?php // print_r($_POST); ?>
|
||||
<form method="POST" id="sefa-form" enctype="multipart/form-data">
|
||||
<?php wp_nonce_field( 'sefa_send_email', 'sefa-form-nonce' ); ?>
|
||||
<table cellpadding="0" border="0" class="form-table">
|
||||
<?php
|
||||
if ( !empty($errors) || $send_mail_message ) {
|
||||
echo '<tr><td colspan="2" id="sefa-messages">';
|
||||
if ( !empty($errors) ) {
|
||||
echo '<div class="error">';
|
||||
foreach ($errors as $error) {
|
||||
echo "$error<br />";
|
||||
}
|
||||
echo "</div>\n";
|
||||
}
|
||||
if ( $send_mail_message ) {
|
||||
echo $send_mail_message;
|
||||
}
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>From:</td>
|
||||
<td><input type="text" disabled value="<?php echo "$from_name <$from_email>"; ?>"><div class="note"><?php _e( 'These can be changed in Settings->General.', 'sefa' ); ?></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>To:</td>
|
||||
<td><input type="email" multiple id="sefa-recipient-emails" name="sefa_recipient_emails" value="<?php echo esc_attr( sefa_plugin_issetor($sefa_recipient_emails) ); ?>"><div class="note"><?php _e( 'To send to multiple recipeints, enter each email address seperated by a comma or choose from the user list below.', 'sefa' ); ?></div>
|
||||
<select id="sefa-user-list">
|
||||
<option value="">-- <?php _e( 'user list', 'sefa' ); ?> --</option>
|
||||
<?php
|
||||
$users = get_users( 'orderby=user_email' );
|
||||
foreach ( $users as $user ) {
|
||||
if ( $user->first_name && $user->last_name ) {
|
||||
$user_fullname = ' (' . $user->first_name . ' ' . $user->last_name . ')';
|
||||
} else {
|
||||
$user_fullname = '';
|
||||
}
|
||||
echo '<option value="' . esc_html( $user->user_email ) . '">' . esc_html( $user->user_email ) . esc_html( $user_fullname) . '</option>';
|
||||
};
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<input type="radio" class="radio" name="sefa_group_email" value="no" id="no" checked>
|
||||
<label for="no"><?php _e( 'Send each recipient an individual email', 'sefa' ); ?></label>
|
||||
|
||||
<input type="radio" class="radio" name="sefa_group_email" value="yes" id="yes"<?php if ( isset($sefa_group_email) && $sefa_group_email === 'yes' ) echo ' checked'; ?>>
|
||||
<label for="yes"><?php _e( 'Send a group email to all recipients', 'sefa' ); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Subject:</td>
|
||||
<td><input type="text" name="sefa_subject" value="<?php echo esc_attr( sefa_plugin_issetor($sefa_subject) );?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Message:</td>
|
||||
<td align="left">
|
||||
<?php
|
||||
$settings = array( "editor_height" => "200" );
|
||||
wp_editor( sefa_plugin_issetor($sefa_body), "sefa_body", $settings );
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Attachment:</td>
|
||||
<td><input type="file" name="attachment"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right">
|
||||
<input type="submit" value="<?php _e( 'Send Message', 'sefa' ); ?>" name="submit" class="button button-primary">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for form values
|
||||
*
|
||||
* @since 0.9
|
||||
*
|
||||
* @param string $var Var name to test isset
|
||||
*
|
||||
* @return string $var value if isset or ''
|
||||
*/
|
||||
function sefa_plugin_issetor(&$var) {
|
||||
return isset($var) ? $var : '';
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user