Rename plugin: Send WP Mail + namespace
This commit is contained in:
parent
36e735ae5a
commit
9b64c8f53c
@ -1,10 +1,10 @@
|
||||
#sefa-wrapper h1 {
|
||||
#swpm-wrapper h1 {
|
||||
font-size: 2.8em;
|
||||
font-weight: 200;
|
||||
margin-bottom: 26px;
|
||||
margin-left: -4px;
|
||||
}
|
||||
#sefa-wrapper h1:before {
|
||||
#swpm-wrapper h1:before {
|
||||
font-family: "dashicons";
|
||||
content: "\f465";
|
||||
top: 8px;
|
||||
@ -12,78 +12,78 @@
|
||||
margin-right: 10px;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
#sefa-wrapper div.error ul li {
|
||||
#swpm-wrapper div.error ul li {
|
||||
list-style: initial;
|
||||
margin-left: 20px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#sefa-wrapper div.updated {
|
||||
#swpm-wrapper div.updated {
|
||||
padding: 10px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
#sefa-form .form-table {
|
||||
#swpm-form .form-table {
|
||||
margin-top: 0;
|
||||
}
|
||||
#sefa-form .form-table tr:first-child th {
|
||||
#swpm-form .form-table tr:first-child th {
|
||||
padding-top: 5px;
|
||||
}
|
||||
#sefa-form .form-table tr:first-child td {
|
||||
#swpm-form .form-table tr:first-child td {
|
||||
padding-top: 0;
|
||||
}
|
||||
#sefa-form .form-table th {
|
||||
#swpm-form .form-table th {
|
||||
width: auto;
|
||||
min-width: 100px;
|
||||
}
|
||||
#sefa-form .form-table td {
|
||||
#swpm-form .form-table td {
|
||||
vertical-align: text-top;
|
||||
}
|
||||
#sefa-form .form-table tr:last-child td {
|
||||
#swpm-form .form-table tr:last-child td {
|
||||
padding: 0 10px;
|
||||
}
|
||||
#sefa-form input[type=text],
|
||||
#sefa-form input[type=email],
|
||||
#sefa-form textarea,
|
||||
#sefa-form .wp-editor-wrap {
|
||||
#swpm-form input[type=text],
|
||||
#swpm-form input[type=email],
|
||||
#swpm-form textarea,
|
||||
#swpm-form .wp-editor-wrap {
|
||||
width: 100%;
|
||||
padding: 6px 10px
|
||||
}
|
||||
#sefa-form .sefa-radio-wrap {
|
||||
#swpm-form .swpm-radio-wrap {
|
||||
display: inline;
|
||||
}
|
||||
#sefa-form .wp-editor-wrap {
|
||||
#swpm-form .wp-editor-wrap {
|
||||
padding-left: 0;
|
||||
}
|
||||
#sefa-form #sefa-user-list {
|
||||
#swpm-form #swpm-user-list {
|
||||
margin-top: 7px;
|
||||
}
|
||||
#sefa-form .note {
|
||||
#swpm-form .note {
|
||||
font-size: 12px;
|
||||
color: #888;
|
||||
padding: 5px 0 0 1px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1300px) {
|
||||
#sefa-wrapper {
|
||||
#swpm-wrapper {
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 900px) {
|
||||
#sefa-form .sefa-radio-wrap {
|
||||
#swpm-form .swpm-radio-wrap {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 850px) {
|
||||
#sefa-wrapper .postbox {
|
||||
#swpm-wrapper .postbox {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 500px) {
|
||||
#sefa-wrapper h1 {
|
||||
#swpm-wrapper h1 {
|
||||
font-size: 2em;
|
||||
margin-left: 0;
|
||||
}
|
||||
#sefa-wrapper h1:before {
|
||||
#swpm-wrapper h1:before {
|
||||
top: 6px;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
$("#sefa-user-list").change( function() {
|
||||
$recipients = $("#sefa-recipient-emails");
|
||||
$("#swpm-user-list").change( function() {
|
||||
$recipients = $("#swpm-recipient-emails");
|
||||
if ( $recipients.val() == '' ) {
|
||||
$recipients.val( $(this).find("option:selected").attr("value") );
|
||||
} else if ( $(this).val() != '' ) {
|
||||
|
||||
139
send-wp-mail.php
139
send-wp-mail.php
@ -1,26 +1,13 @@
|
||||
<?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: 1.0
|
||||
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/>.
|
||||
*/
|
||||
/**
|
||||
* Plugin Name: Send WP Mail
|
||||
* Update URI: false
|
||||
* Description: Send email from WordPress. Sends email using WordPress core wp_mail function - if enabled.
|
||||
* Version: 1.1
|
||||
* Author: abuyoyo
|
||||
* Domain Path: /languages
|
||||
* Text Domain: swpm
|
||||
*/
|
||||
|
||||
|
||||
# Exit if accessed directly
|
||||
@ -28,30 +15,30 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
define( 'SEFA_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) );
|
||||
define( 'SEFA_PLUGIN_VER', '0.9.3' );
|
||||
define( 'SWPM_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) );
|
||||
define( 'SWPM_PLUGIN_VER', '0.9.3' );
|
||||
|
||||
/**
|
||||
* Add our sub menu in the Tools menu
|
||||
*
|
||||
* @since 0.9.2
|
||||
*/
|
||||
function sefa_plugin_add_admin_page() {
|
||||
// create sefa submenu page under the Tools menu
|
||||
$sefa_page = add_submenu_page( 'tools.php', 'Send Email From Admin', 'Send Email', 'manage_options', 'sefa_email', 'sefa_plugin_main' );
|
||||
// load js and css on sefa page only
|
||||
add_action( 'load-' . $sefa_page, 'sefa_plugin_scripts' );
|
||||
function swpm_plugin_add_admin_page() {
|
||||
// create swpm submenu page under the Tools menu
|
||||
$swpm_page = add_submenu_page( 'tools.php', 'Send WP Mail', 'Send Email', 'manage_options', 'send-wp-mail', 'swpm_plugin_main' );
|
||||
// load js and css on swpm page only
|
||||
add_action( 'load-' . $swpm_page, 'swpm_plugin_scripts' );
|
||||
}
|
||||
add_action( 'admin_menu', 'sefa_plugin_add_admin_page' );
|
||||
add_action( 'admin_menu', 'swpm_plugin_add_admin_page' );
|
||||
|
||||
/**
|
||||
* Load our css and js.
|
||||
*
|
||||
* @since 0.9.2
|
||||
*/
|
||||
function sefa_plugin_scripts() {
|
||||
wp_enqueue_style( 'sefa_admin_css', SEFA_PLUGIN_DIR_URL . 'css/send-wp-mail.css', '', SEFA_PLUGIN_VER );
|
||||
wp_enqueue_script( 'sefa_admin_js', SEFA_PLUGIN_DIR_URL . 'js/send-wp-mail.js', array('jquery'), SEFA_PLUGIN_VER);
|
||||
function swpm_plugin_scripts() {
|
||||
wp_enqueue_style( 'swpm_admin_css', SWPM_PLUGIN_DIR_URL . 'css/send-wp-mail.css', '', SWPM_PLUGIN_VER );
|
||||
wp_enqueue_script( 'swpm_admin_js', SWPM_PLUGIN_DIR_URL . 'js/send-wp-mail.js', array('jquery'), SWPM_PLUGIN_VER);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,17 +46,17 @@ function sefa_plugin_scripts() {
|
||||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
function sefa_plugin_load_textdomain() {
|
||||
load_plugin_textdomain( 'sefa', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
|
||||
function swpm_plugin_load_textdomain() {
|
||||
load_plugin_textdomain( 'swpm', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
|
||||
}
|
||||
add_action('plugins_loaded', 'sefa_plugin_load_textdomain');
|
||||
add_action('plugins_loaded', 'swpm_plugin_load_textdomain');
|
||||
|
||||
/**
|
||||
* Our main function to display and process our form
|
||||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
function sefa_plugin_main() {
|
||||
function swpm_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');
|
||||
@ -77,7 +64,7 @@ function sefa_plugin_main() {
|
||||
// initialize
|
||||
$send_mail_message = false;
|
||||
|
||||
if ( !empty( $_POST ) && check_admin_referer( 'sefa_send_email', 'sefa-form-nonce' ) ) {
|
||||
if ( !empty( $_POST ) && check_admin_referer( 'send-wp-mail', 'send-wp-mail' ) ) {
|
||||
// handle attachment
|
||||
$attachment_path = '';
|
||||
if ( $_FILES ) {
|
||||
@ -96,19 +83,19 @@ function sefa_plugin_main() {
|
||||
}
|
||||
|
||||
// get the posted form values
|
||||
$sefa_recipient_emails = isset( $_POST['sefa_recipient_emails'] ) ? trim($_POST['sefa_recipient_emails']) : '';
|
||||
$sefa_subject = isset( $_POST['sefa_subject'] ) ? stripslashes(trim($_POST['sefa_subject'])) : '';
|
||||
$sefa_body = isset( $_POST['sefa_body'] ) ? stripslashes(nl2br($_POST['sefa_body'])) : '';
|
||||
$sefa_group_email = isset( $_POST['sefa_group_email'] ) ? trim($_POST['sefa_group_email']) : 'no';
|
||||
$recipients = explode( ',',$sefa_recipient_emails );
|
||||
$email_to = isset( $_POST['email_to'] ) ? trim($_POST['email_to']) : '';
|
||||
$email_subject = isset( $_POST['email_subject'] ) ? stripslashes(trim($_POST['email_subject'])) : '';
|
||||
$email_body = isset( $_POST['email_body'] ) ? stripslashes(nl2br($_POST['email_body'])) : '';
|
||||
$group_email = isset( $_POST['group_email'] ) ? trim($_POST['group_email']) : 'no';
|
||||
$recipients = explode( ',',$email_to );
|
||||
|
||||
// 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' );
|
||||
if ( empty( $email_to ) ) {
|
||||
$errors[] = __( "Please enter an email recipient in the To: field.", 'swpm' );
|
||||
} else {
|
||||
// Loop through each email and validate it
|
||||
foreach( $recipients as $recipient ) {
|
||||
@ -119,11 +106,11 @@ function sefa_plugin_main() {
|
||||
}
|
||||
// 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' );
|
||||
$errors[] = _n( "The To: email address appears to be invalid.", "One of the To: email addresses appears to be invalid.", count($recipients), 'swpm' );
|
||||
}
|
||||
}
|
||||
if ( empty($sefa_subject) ) $errors[] = __( "Please enter a Subject.", 'sefa' );
|
||||
if ( empty($sefa_body) ) $errors[] = __( "Please enter a Message.", 'sefa' );
|
||||
if ( empty($email_subject) ) $errors[] = __( "Please enter a Subject.", 'swpm' );
|
||||
if ( empty($email_body) ) $errors[] = __( "Please enter a Message.", 'swpm' );
|
||||
|
||||
// send the email if no errors were found
|
||||
if ( empty($errors) ) {
|
||||
@ -131,18 +118,18 @@ function sefa_plugin_main() {
|
||||
$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>';
|
||||
if ( $group_email === 'yes' ) {
|
||||
if ( wp_mail( $email_to, $email_subject, $email_body, $headers, $attachments ) ) {
|
||||
$send_mail_message = '<div class="updated">' . __( 'Your email has been successfully sent!', 'swpm' ) . '</div>';
|
||||
} else {
|
||||
$send_mail_message = '<div class="error">' . __( 'There was an error sending the email.', 'sefa' ) . '</div>';
|
||||
$send_mail_message = '<div class="error">' . __( 'There was an error sending the email.', 'swpm' ) . '</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>';
|
||||
if ( wp_mail( $recipient, $email_subject, $email_body, $headers, $attachments ) ) {
|
||||
$send_mail_message .= '<div class="updated">' . __( 'Your email has been successfully sent to ', 'swpm' ) . esc_html($recipient) . '!</div>';
|
||||
} else {
|
||||
$send_mail_message .= '<div class="error">' . __( 'There was an error sending the email to ', 'sefa' ) . esc_html($recipient) . '</div>';
|
||||
$send_mail_message .= '<div class="error">' . __( 'There was an error sending the email to ', 'swpm' ) . esc_html($recipient) . '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -154,8 +141,8 @@ function sefa_plugin_main() {
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="wrap" id="sefa-wrapper">
|
||||
<h1><?php _e( 'Send Email From Admin', 'sefa' ); ?></h1>
|
||||
<div class="wrap" id="swpm-wrapper">
|
||||
<h1><?php _e( 'Send WP Mail', 'swpm' ); ?></h1>
|
||||
<?php
|
||||
if ( !empty($errors) ) {
|
||||
echo '<div class="error"><ul>';
|
||||
@ -171,18 +158,18 @@ function sefa_plugin_main() {
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder columns-2">
|
||||
<div id="post-body-content">
|
||||
<form method="POST" id="sefa-form" enctype="multipart/form-data">
|
||||
<?php wp_nonce_field( 'sefa_send_email', 'sefa-form-nonce' ); ?>
|
||||
<form method="POST" id="swpm-form" enctype="multipart/form-data">
|
||||
<?php wp_nonce_field( 'send-wp-mail', 'send-wp-mail' ); ?>
|
||||
<table cellpadding="0" border="0" class="form-table">
|
||||
<tr>
|
||||
<th scope=”row”>From:</th>
|
||||
<td><input type="text" disabled value="<?php echo "$from_name <$from_email>"; ?>" required><div class="note"><?php _e( 'These can be changed in Settings->General.', 'sefa' ); ?></div></td>
|
||||
<td><input type="text" disabled value="<?php echo "$from_name <$from_email>"; ?>" required><div class="note"><?php _e( 'These can be changed in Settings->General.', 'swpm' ); ?></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope=”row”><label for="sefa-recipient-emails">To:</label></th>
|
||||
<td><input type="email" multiple id="sefa-recipient-emails" name="sefa_recipient_emails" value="<?php echo esc_attr( sefa_plugin_issetor($sefa_recipient_emails) ); ?>" required><div class="note"><?php _e( 'To send to multiple recipients, enter each email address separated 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>
|
||||
<th scope=”row”><label for="swpm-recipient-emails">To:</label></th>
|
||||
<td><input type="email" multiple id="swpm-recipient-emails" name="email_to" value="<?php echo esc_attr( swpm_plugin_issetor($email_to) ); ?>" required><div class="note"><?php _e( 'To send to multiple recipients, enter each email address separated by a comma or choose from the user list below.', 'swpm' ); ?></div>
|
||||
<select id="swpm-user-list">
|
||||
<option value="">-- <?php _e( 'user list', 'swpm' ); ?> --</option>
|
||||
<?php
|
||||
$users = get_users( 'orderby=user_email' );
|
||||
foreach ( $users as $user ) {
|
||||
@ -200,27 +187,27 @@ function sefa_plugin_main() {
|
||||
<tr>
|
||||
<th scope=”row”></th>
|
||||
<td>
|
||||
<div class="sefa-radio-wrap">
|
||||
<input type="radio" class="radio" name="sefa_group_email" value="no" id="no"<?php if ( isset($sefa_group_email) && $sefa_group_email === 'no' ) echo ' checked'; ?> required>
|
||||
<label for="no"><?php _e( 'Send each recipient an individual email', 'sefa' ); ?></label>
|
||||
<div class="swpm-radio-wrap">
|
||||
<input type="radio" class="radio" name="group_email" value="no" id="no"<?php if ( isset($group_email) && $group_email === 'no' ) echo ' checked'; ?> required>
|
||||
<label for="no"><?php _e( 'Send each recipient an individual email', 'swpm' ); ?></label>
|
||||
</div>
|
||||
|
||||
<div class="sefa-radio-wrap">
|
||||
<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'; ?> required>
|
||||
<label for="yes"><?php _e( 'Send a group email to all recipients', 'sefa' ); ?></label>
|
||||
<div class="swpm-radio-wrap">
|
||||
<input type="radio" class="radio" name="group_email" value="yes" id="yes"<?php if ( isset($group_email) && $group_email === 'yes' ) echo ' checked'; ?> required>
|
||||
<label for="yes"><?php _e( 'Send a group email to all recipients', 'swpm' ); ?></label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope=”row”><label for="sefa-subject">Subject:</label></th>
|
||||
<td><input type="text" id="sefa-subject" name="sefa_subject" value="<?php echo esc_attr( sefa_plugin_issetor($sefa_subject) );?>" required></td>
|
||||
<th scope=”row”><label for="swpm-subject">Subject:</label></th>
|
||||
<td><input type="text" id="swpm-subject" name="email_subject" value="<?php echo esc_attr( swpm_plugin_issetor($email_subject) );?>" required></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope=”row”><label for="sefa_body">Message:</label></th>
|
||||
<th scope=”row”><label for="email_body">Message:</label></th>
|
||||
<td align="left">
|
||||
<?php
|
||||
$settings = array( "editor_height" => "200" );
|
||||
wp_editor( sefa_plugin_issetor($sefa_body), "sefa_body", $settings );
|
||||
wp_editor( swpm_plugin_issetor($email_body), "email_body", $settings );
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
@ -230,7 +217,7 @@ function sefa_plugin_main() {
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right">
|
||||
<input type="submit" value="<?php _e( 'Send Email', 'sefa' ); ?>" name="submit" class="button button-primary">
|
||||
<input type="submit" value="<?php _e( 'Send WP Mail', 'swpm' ); ?>" name="submit" class="button button-primary">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -263,6 +250,6 @@ function sefa_plugin_main() {
|
||||
*
|
||||
* @return string $var value if isset or ''
|
||||
*/
|
||||
function sefa_plugin_issetor(&$var) {
|
||||
function swpm_plugin_issetor(&$var) {
|
||||
return isset($var) ? $var : '';
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user