Skip to content

Commit

Permalink
Merge branch 'version_401'
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelldmiller committed Nov 15, 2020
2 parents 9eaaeb6 + dddb057 commit 1d3fb9f
Show file tree
Hide file tree
Showing 4 changed files with 325 additions and 333 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Quick Mail WordPress Plugin
====================

Send text or html email with attachments and shortcodes from WP Dashboard or command line. Send private replies to comments. Select recipient from users or commenters. Includes WP-CLI command.

* __NEWS:__ [I removed Quick Mail](http://web.archive.org/web/20191214214738/https://wheredidmybraingo.com/my-final-quick-mail-update/) from the WordPress Plugin Repository on November 14, 2019.
* __NOTE:__ Quick Mail was [removed](http://web.archive.org/web/20191214214738/https://wheredidmybraingo.com/my-final-quick-mail-update/) from the WordPress Plugin Repository on November 14, 2019.

* Please use [Github Issues](https://github.com/mitchelldmiller/quick-mail-wp-plugin/issues) for support.

Expand Down Expand Up @@ -81,7 +80,8 @@ __Who can send mail?__

* Users must be able to [publish a post](http://codex.wordpress.org/Roles_and_Capabilities#publish_posts) to send an email.

* WP-CLI: Only administrators can send mail with the `quick-mail` WP-CLI command.
* WP-CLI: By default, only administrators can send mail with the `quick-mail` WP-CLI command. Use the
the [quick_mail_cli_admin_only](https://wheredidmybraingo.com/whats-new-in-quick-mail-4-0-1) filter to change this.

__Who can send rich text messages?__

Expand Down Expand Up @@ -218,12 +218,16 @@ __Customizing Quick Mail__
Replace title for private comment reply on comments list.

`quick_mail_user_capability`

Replace minimum user capability.


`quick_mail_cli_admin_only`

Allow non-admin users to send mail with WP-CLI.

__Additional Information__

* [39 articles about Quick Mail](https://wheredidmybraingo.com/tag/quick-mail/)
* [40 articles about Quick Mail](https://wheredidmybraingo.com/tag/quick-mail/)

__Translators and Programmers__

Expand Down
24 changes: 17 additions & 7 deletions inc/class-quick-mail-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Mail a Web page or file with quick-mail and WP-CLI.
*
* @package QuickMail
* @version 3.5.3
*/
class Quick_Mail_Command extends WP_CLI_Command {

Expand Down Expand Up @@ -65,6 +64,7 @@ class Quick_Mail_Command extends WP_CLI_Command {
*
* <from>
* : Sender. Must be Administrator. Enter WordPress user ID or email address.
* Filter `quick_mail_cli_admin_only` to allow non-admin to send mail.
*
* <to>
* : Mail recipient. Enter WordPress user ID, WP role or email address.
Expand Down Expand Up @@ -147,7 +147,8 @@ public function __invoke( $args, $assoc_args ) {
$verify_domain = get_option( 'verify_quick_mail_addresses', 'N' );
} // end if multisite

$data = $this->verify_email_or_id( $args[0], true ); // Admin only.
$only_admin = apply_filters( 'quick_mail_cli_admin_only', true );
$data = $this->verify_email_or_id( $args[0], $only_admin ); // Admin only.
if ( is_array( $data ) && ! empty( $data[0] ) && ! empty( $data[1] ) ) {
$this->from = $data[0];
$sender_id = $data[1];
Expand Down Expand Up @@ -240,11 +241,19 @@ public function __invoke( $args, $assoc_args ) {
$subject = isset( $args[3] ) ? html_entity_decode( $args[3], ENT_QUOTES, self::$charset ) : '';

// Get sender info.
$query_args = array(
'search' => $this->from,
'search_columns' => array( 'user_email' ),
'role' => 'Administrator',
);
$query_args = array();
if ( $only_admin ) {
$query_args = array(
'search' => $this->from,
'search_columns' => array( 'user_email' ),
'role' => 'Administrator',
);
} else {
$query_args = array(
'search' => $this->from,
'search_columns' => array( 'user_email' ),
);
}
$user_query = new WP_User_Query( $query_args );
if ( 1 > count( $user_query->results ) ) {
$temp_msg = __( 'Invalid user', 'quick-mail' );
Expand Down Expand Up @@ -304,6 +313,7 @@ public function __invoke( $args, $assoc_args ) {

if ( ! $sending_file && empty( $subject ) ) {
$pattern = '/title>(.+)<\/title>/';
$found = array();
preg_match( $pattern, $message, $found );
if ( ! empty( $found ) && ! empty( $found[1] ) ) {
$subject = html_entity_decode( $found[1], ENT_QUOTES, self::$charset );
Expand Down
Loading

0 comments on commit 1d3fb9f

Please sign in to comment.