From 36e735ae5a479786dae6e45ed1222a81dc6d3970 Mon Sep 17 00:00:00 2001 From: abuyoyo Date: Sun, 3 Nov 2024 23:12:22 +0200 Subject: [PATCH] Rename files send-wp-mail --- css/{sefa.css => send-wp-mail.css} | 176 +++--- js/{sefa.js => send-wp-mail.js} | 0 send-email-from-admin.php => send-wp-mail.php | 534 +++++++++--------- 3 files changed, 355 insertions(+), 355 deletions(-) rename css/{sefa.css => send-wp-mail.css} (94%) rename js/{sefa.js => send-wp-mail.js} (100%) rename send-email-from-admin.php => send-wp-mail.php (96%) diff --git a/css/sefa.css b/css/send-wp-mail.css similarity index 94% rename from css/sefa.css rename to css/send-wp-mail.css index 618ec88..a1844df 100644 --- a/css/sefa.css +++ b/css/send-wp-mail.css @@ -1,89 +1,89 @@ -#sefa-wrapper h1 { - font-size: 2.8em; - font-weight: 200; - margin-bottom: 26px; - margin-left: -4px; -} -#sefa-wrapper h1:before { - font-family: "dashicons"; - content: "\f465"; - top: 8px; - position: relative; - margin-right: 10px; - font-size: 1.2em; -} -#sefa-wrapper div.error ul li { - list-style: initial; - margin-left: 20px; - margin-bottom: 0; -} -#sefa-wrapper div.updated { - padding: 10px; - margin-bottom: 5px; -} -#sefa-form .form-table { - margin-top: 0; -} -#sefa-form .form-table tr:first-child th { - padding-top: 5px; -} -#sefa-form .form-table tr:first-child td { - padding-top: 0; -} -#sefa-form .form-table th { - width: auto; - min-width: 100px; -} -#sefa-form .form-table td { - vertical-align: text-top; -} -#sefa-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 { - width: 100%; - padding: 6px 10px -} -#sefa-form .sefa-radio-wrap { - display: inline; -} -#sefa-form .wp-editor-wrap { - padding-left: 0; -} -#sefa-form #sefa-user-list { - margin-top: 7px; -} -#sefa-form .note { - font-size: 12px; - color: #888; - padding: 5px 0 0 1px; -} - -@media screen and (max-width: 1300px) { - #sefa-wrapper { - width: 100%; - margin-left: 0; - } -} -@media screen and (max-width: 900px) { - #sefa-form .sefa-radio-wrap { - display: block; - } -} -@media screen and (max-width: 850px) { - #sefa-wrapper .postbox { - margin-right: 10px; - } -} -@media screen and (max-width: 500px) { - #sefa-wrapper h1 { - font-size: 2em; - margin-left: 0; - } - #sefa-wrapper h1:before { - top: 6px; - } +#sefa-wrapper h1 { + font-size: 2.8em; + font-weight: 200; + margin-bottom: 26px; + margin-left: -4px; +} +#sefa-wrapper h1:before { + font-family: "dashicons"; + content: "\f465"; + top: 8px; + position: relative; + margin-right: 10px; + font-size: 1.2em; +} +#sefa-wrapper div.error ul li { + list-style: initial; + margin-left: 20px; + margin-bottom: 0; +} +#sefa-wrapper div.updated { + padding: 10px; + margin-bottom: 5px; +} +#sefa-form .form-table { + margin-top: 0; +} +#sefa-form .form-table tr:first-child th { + padding-top: 5px; +} +#sefa-form .form-table tr:first-child td { + padding-top: 0; +} +#sefa-form .form-table th { + width: auto; + min-width: 100px; +} +#sefa-form .form-table td { + vertical-align: text-top; +} +#sefa-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 { + width: 100%; + padding: 6px 10px +} +#sefa-form .sefa-radio-wrap { + display: inline; +} +#sefa-form .wp-editor-wrap { + padding-left: 0; +} +#sefa-form #sefa-user-list { + margin-top: 7px; +} +#sefa-form .note { + font-size: 12px; + color: #888; + padding: 5px 0 0 1px; +} + +@media screen and (max-width: 1300px) { + #sefa-wrapper { + width: 100%; + margin-left: 0; + } +} +@media screen and (max-width: 900px) { + #sefa-form .sefa-radio-wrap { + display: block; + } +} +@media screen and (max-width: 850px) { + #sefa-wrapper .postbox { + margin-right: 10px; + } +} +@media screen and (max-width: 500px) { + #sefa-wrapper h1 { + font-size: 2em; + margin-left: 0; + } + #sefa-wrapper h1:before { + top: 6px; + } } \ No newline at end of file diff --git a/js/sefa.js b/js/send-wp-mail.js similarity index 100% rename from js/sefa.js rename to js/send-wp-mail.js diff --git a/send-email-from-admin.php b/send-wp-mail.php similarity index 96% rename from send-email-from-admin.php rename to send-wp-mail.php index 6bcd3ce..313d08a 100644 --- a/send-email-from-admin.php +++ b/send-wp-mail.php @@ -1,268 +1,268 @@ - 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 . -*/ - - -# Exit if accessed directly -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - -define( 'SEFA_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) ); -define( 'SEFA_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' ); -} -add_action( 'admin_menu', 'sefa_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/sefa.css', '', SEFA_PLUGIN_VER ); - wp_enqueue_script( 'sefa_admin_js', SEFA_PLUGIN_DIR_URL . 'js/sefa.js', array('jquery'), SEFA_PLUGIN_VER); -} - -/** - * 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'] ) ? 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 ); - - // 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 = '
' . __( 'Your email has been successfully sent!', 'sefa' ) . '
'; - } else { - $send_mail_message = '
' . __( 'There was an error sending the email.', 'sefa' ) . '
'; - } - } else { - foreach( $recipients as $recipient ) { - if ( wp_mail( $recipient, $sefa_subject, $sefa_body, $headers, $attachments ) ) { - $send_mail_message .= '
' . __( 'Your email has been successfully sent to ', 'sefa' ) . esc_html($recipient) . '!
'; - } else { - $send_mail_message .= '
' . __( 'There was an error sending the email to ', 'sefa' ) . esc_html($recipient) . '
'; - } - } - } - - // delete the uploaded file (attachment) from the server - if ( $attachment_path ) { - unlink($attachment_path); - } - } - } - ?> -
-

-
    '; - foreach ($errors as $error) { - echo "
  • $error
  • "; - } - echo "
\n"; - } - if ( $send_mail_message ) { - echo $send_mail_message; - } - ?> -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
From:" required>
General.', 'sefa' ); ?>
- -
-
- required> - -
-    -
- required> - -
-
- "200" ); - wp_editor( sefa_plugin_issetor($sefa_body), "sefa_body", $settings ); - ?> -
- -
-
-
-
-
-

Like this plugin?

- -
-
-
-
-
- - 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 . +*/ + + +# Exit if accessed directly +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + +define( 'SEFA_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) ); +define( 'SEFA_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' ); +} +add_action( 'admin_menu', 'sefa_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); +} + +/** + * 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'] ) ? 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 ); + + // 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 = '
' . __( 'Your email has been successfully sent!', 'sefa' ) . '
'; + } else { + $send_mail_message = '
' . __( 'There was an error sending the email.', 'sefa' ) . '
'; + } + } else { + foreach( $recipients as $recipient ) { + if ( wp_mail( $recipient, $sefa_subject, $sefa_body, $headers, $attachments ) ) { + $send_mail_message .= '
' . __( 'Your email has been successfully sent to ', 'sefa' ) . esc_html($recipient) . '!
'; + } else { + $send_mail_message .= '
' . __( 'There was an error sending the email to ', 'sefa' ) . esc_html($recipient) . '
'; + } + } + } + + // delete the uploaded file (attachment) from the server + if ( $attachment_path ) { + unlink($attachment_path); + } + } + } + ?> +
+

+
    '; + foreach ($errors as $error) { + echo "
  • $error
  • "; + } + echo "
\n"; + } + if ( $send_mail_message ) { + echo $send_mail_message; + } + ?> +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
From:" required>
General.', 'sefa' ); ?>
+ +
+
+ required> + +
+    +
+ required> + +
+
+ "200" ); + wp_editor( sefa_plugin_issetor($sefa_body), "sefa_body", $settings ); + ?> +
+ +
+
+
+
+
+

Like this plugin?

+ +
+
+
+
+
+ +