Changeset 2672700
- Timestamp:
- 02/04/2022 07:25:36 AM (4 years ago)
- Location:
- juvo-mail-editor
- Files:
-
- 38 edited
- 1 copied
-
tags/3.0.5 (copied) (copied from juvo-mail-editor/trunk)
-
tags/3.0.5/juvo-mail-editor.php (modified) (1 diff)
-
tags/3.0.5/readme.txt (modified) (2 diffs)
-
tags/3.0.5/src/Mail_Generator.php (modified) (1 diff)
-
tags/3.0.5/src/Mails/Generic.php (modified) (3 diffs)
-
tags/3.0.5/src/Mails/Mail.php (modified) (1 diff)
-
tags/3.0.5/src/Mails/New_User.php (modified) (2 diffs)
-
tags/3.0.5/src/Mails/New_User_Admin.php (modified) (2 diffs)
-
tags/3.0.5/src/Mails/New_User_Admin_Rest.php (modified) (2 diffs)
-
tags/3.0.5/src/Mails/New_User_Rest.php (modified) (2 diffs)
-
tags/3.0.5/src/Mails/Password_Changed.php (modified) (2 diffs)
-
tags/3.0.5/src/Mails/Password_Changed_Admin.php (modified) (1 diff)
-
tags/3.0.5/src/Mails/Password_Reset.php (modified) (2 diffs)
-
tags/3.0.5/src/Mails/Password_Reset_Admin.php (modified) (2 diffs)
-
tags/3.0.5/src/Mails_PT.php (modified) (2 diffs)
-
tags/3.0.5/src/Relay.php (modified) (8 diffs)
-
tags/3.0.5/vendor/autoload.php (modified) (1 diff)
-
tags/3.0.5/vendor/composer/autoload_real.php (modified) (5 diffs)
-
tags/3.0.5/vendor/composer/autoload_static.php (modified) (2 diffs)
-
tags/3.0.5/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/juvo-mail-editor.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Mail_Generator.php (modified) (1 diff)
-
trunk/src/Mails/Generic.php (modified) (3 diffs)
-
trunk/src/Mails/Mail.php (modified) (1 diff)
-
trunk/src/Mails/New_User.php (modified) (2 diffs)
-
trunk/src/Mails/New_User_Admin.php (modified) (2 diffs)
-
trunk/src/Mails/New_User_Admin_Rest.php (modified) (2 diffs)
-
trunk/src/Mails/New_User_Rest.php (modified) (2 diffs)
-
trunk/src/Mails/Password_Changed.php (modified) (2 diffs)
-
trunk/src/Mails/Password_Changed_Admin.php (modified) (1 diff)
-
trunk/src/Mails/Password_Reset.php (modified) (2 diffs)
-
trunk/src/Mails/Password_Reset_Admin.php (modified) (2 diffs)
-
trunk/src/Mails_PT.php (modified) (2 diffs)
-
trunk/src/Relay.php (modified) (8 diffs)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (5 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
juvo-mail-editor/tags/3.0.5/juvo-mail-editor.php
r2665461 r2672700 8 8 * Text Domain: juvo-mail-editor 9 9 * Domain Path: /languages 10 * Version: 3.0. 410 * Version: 3.0.5 11 11 */ 12 12 -
juvo-mail-editor/tags/3.0.5/readme.txt
r2665461 r2672700 4 4 License: GPLv2 or later 5 5 Tested up to: 5.9 6 Stable tag: 3.0. 46 Stable tag: 3.0.5 7 7 8 8 JUVO Mail Editor helps to modify the standard WordPress Mailings and allows adding dynamic mail triggers. … … 22 22 * Seamless integration to any mail styling plugin - even buddyboss. 23 23 * Multilanguage support 24 * Set CC, BCC and Attachments for mails 24 25 25 26 == Frequently Asked Questions == -
juvo-mail-editor/tags/3.0.5/src/Mail_Generator.php
r2655718 r2672700 14 14 add_filter( 'juvo_mail_editor_trigger', array( $this, 'registerTrigger' ) ); 15 15 16 add_filter( "juvo_mail_editor_{$this->getTrigger()}_always_sent", array( $this, 'getAlwaysSent' ), 1 , 0 );17 add_filter( "juvo_mail_editor_{$this->getTrigger()}_subject", array( $this, 'getSubject' ), 1 , 0);18 add_filter( "juvo_mail_editor_{$this->getTrigger()}_message", array( $this, 'getMessage' ), 1 , 0);19 add_filter( "juvo_mail_editor_{$this->getTrigger()}_ default_recipients", array( $this, 'getRecipient' ), 1, 0);16 add_filter( "juvo_mail_editor_{$this->getTrigger()}_always_sent", array( $this, 'getAlwaysSent' ), 10, 0 ); 17 add_filter( "juvo_mail_editor_{$this->getTrigger()}_subject", array( $this, 'getSubject' ), 10, 1 ); 18 add_filter( "juvo_mail_editor_{$this->getTrigger()}_message", array( $this, 'getMessage' ), 10, 1 ); 19 add_filter( "juvo_mail_editor_{$this->getTrigger()}_recipients", array( $this, 'getRecipients' ), 10, 1 ); 20 20 add_filter( 21 21 "juvo_mail_editor_{$this->getTrigger()}_placeholders", -
juvo-mail-editor/tags/3.0.5/src/Mails/Generic.php
r2665450 r2672700 10 10 private $recipients; 11 11 private $headers; 12 private $attachments; 12 13 13 14 /** … … 16 17 * @param string $subject 17 18 * @param string $content 18 * @param string $recipients 19 * @param array $recipients 20 * @param array $headers 21 * @param array $attachments 19 22 */ 20 public function __construct( string $subject, string $content, string $recipients, array $headers ) { 21 $this->subject = $subject; 22 $this->content = $content; 23 $this->recipients = $recipients; 24 $this->headers = $headers; 23 public function __construct( string $subject, string $content, array $recipients, array $headers, array $attachments ) { 24 $this->subject = $subject; 25 $this->content = $content; 26 $this->recipients = $recipients; 27 $this->headers = $headers; 28 $this->attachments = $attachments; 25 29 } 26 30 … … 29 33 */ 30 34 public function send() { 31 return wp_mail( $this->recipients, $this->subject, $this->content, $this->headers );35 return wp_mail( $this->recipients, $this->subject, $this->content, $this->headers, $this->attachments ); 32 36 } 33 37 } -
juvo-mail-editor/tags/3.0.5/src/Mails/Mail.php
r2655718 r2672700 5 5 interface Mail { 6 6 7 public function getSubject( ): string;7 public function getSubject( string $subject ): string; 8 8 9 public function getMessage( ): string;9 public function getMessage( string $message ): string; 10 10 11 public function getRecipient (): string;11 public function getRecipients( array $recipients ): array; 12 12 13 13 public function getAlwaysSent(): bool; -
juvo-mail-editor/tags/3.0.5/src/Mails/New_User.php
r2655718 r2672700 39 39 } 40 40 41 public function getSubject(): string { 41 public function getSubject( string $subject ): string { 42 43 if ( ! empty( $subject ) ) { 44 return $subject; 45 } 46 42 47 return sprintf( __( '%s Login Details', 'default' ), '{{site.name}}' ); 43 48 } 44 49 45 public function getMessage(): string { 50 public function getMessage( string $message ): string { 51 52 if ( ! empty( $message ) ) { 53 return $message; 54 } 55 46 56 $message = sprintf( __( 'Username: %s', 'default' ), '{{user.name}}' ) . "\r\n\r\n"; 47 57 $message .= __( 'To set your password, visit the following address:', 'default' ) . "\r\n\r\n"; … … 51 61 } 52 62 53 public function getRecipient(): string { 54 return '{{user.user_email}}'; 63 public function getRecipients( array $recipients ): array { 64 65 if ( ! empty( $recipients ) ) { 66 return $recipients; 67 } 68 69 return [ '{{user.user_email}}' ]; 55 70 } 56 71 -
juvo-mail-editor/tags/3.0.5/src/Mails/New_User_Admin.php
r2655718 r2672700 17 17 public function prepareSend( array $email, WP_User $user ): array { 18 18 do_action( "juvo_mail_editor_send", $this->getTrigger(), [ "user" => $user ] ); 19 19 20 return $this->emptyMailArray( $email ); 20 21 } 21 22 22 public function getSubject(): string { 23 public function getSubject( string $subject ): string { 24 25 if ( ! empty( $subject ) ) { 26 return $subject; 27 } 28 23 29 return sprintf( __( '[%s] New User Registration', 'default' ), '{{site.name}}' ); 24 30 } 25 31 26 public function getMessage(): string { 32 public function getMessage( string $message ): string { 33 34 if ( ! empty( $message ) ) { 35 return $message; 36 } 37 27 38 $message = sprintf( __( 'New user registration on your site %s:', 'default' ), '{{site.name}}' ) . "\r\n\r\n"; 28 39 $message .= sprintf( __( 'Username: %s', 'default' ), '{{user.name}}' ) . "\r\n\r\n"; … … 32 43 } 33 44 34 public function getRecipient(): string { 35 return '{{site.admin_email}}'; 45 public function getRecipients( array $recipients ): array { 46 47 if ( ! empty( $recipients ) ) { 48 return $recipients; 49 } 50 51 return [ '{{site.admin_email}}' ]; 36 52 } 37 53 -
juvo-mail-editor/tags/3.0.5/src/Mails/New_User_Admin_Rest.php
r2655718 r2672700 19 19 } 20 20 21 public function getSubject(): string { 21 public function getSubject( string $subject ): string { 22 23 if ( ! empty( $subject ) ) { 24 return $subject; 25 } 26 22 27 return sprintf( __( '[%s] New User Registration', 'default' ), '{{site.name}}' ); 23 28 } 24 29 25 public function getMessage(): string { 30 public function getMessage( string $message ): string { 31 32 if ( ! empty( $message ) ) { 33 return $message; 34 } 35 26 36 $message = sprintf( __( 'New user registration on your site %s:', 'default' ), '{{site.name}}' ) . "\r\n\r\n"; 27 37 $message .= sprintf( __( 'Username: %s', 'default' ), '{{user.name}}' ) . "\r\n\r\n"; … … 31 41 } 32 42 33 public function getRecipient(): string { 34 return '{{site.admin_email}}'; 43 public function getRecipients( array $recipients ): array { 44 45 if ( ! empty( $recipients ) ) { 46 return $recipients; 47 } 48 49 return [ '{{site.admin_email}}' ]; 35 50 } 36 51 -
juvo-mail-editor/tags/3.0.5/src/Mails/New_User_Rest.php
r2655718 r2672700 46 46 } 47 47 48 public function getSubject(): string { 48 public function getSubject( string $subject ): string { 49 50 if ( ! empty( $subject ) ) { 51 return $subject; 52 } 53 49 54 return sprintf( __( '%s Login Details', 'default' ), '{{site.name}}' ); 50 55 } 51 56 52 public function getMessage(): string { 57 public function getMessage( string $message ): string { 58 59 if ( ! empty( $message ) ) { 60 return $message; 61 } 62 53 63 $message = sprintf( __( 'Username: %s', 'default' ), '{{user.name}}' ) . "\r\n\r\n"; 54 64 $message .= __( 'To set your password, visit the following address:', 'default' ) . "\r\n\r\n"; … … 58 68 } 59 69 60 public function getRecipient(): string { 61 return '{{user.user_email}}'; 70 public function getRecipients( array $recipients ): array { 71 72 if ( ! empty( $recipients ) ) { 73 return $recipients; 74 } 75 76 return [ '{{user.user_email}}' ]; 62 77 } 63 78 -
juvo-mail-editor/tags/3.0.5/src/Mails/Password_Changed.php
r2655718 r2672700 24 24 } 25 25 26 public function getSubject(): string { 26 public function getSubject( string $subject ): string { 27 28 if ( ! empty( $subject ) ) { 29 return $subject; 30 } 31 27 32 return sprintf( __( '%s Password Changed', 'default' ), '{{site.name}}' ); 28 33 } 29 34 30 public function getMessage(): string { 35 public function getMessage( string $message ): string { 36 37 if ( ! empty( $message ) ) { 38 return $message; 39 } 40 31 41 $message = __( 32 42 'Hi ###USERNAME###, … … 60 70 } 61 71 62 public function getRecipient(): string { 63 return '{{user.user_email}}'; 72 public function getRecipients( array $recipients ): array { 73 74 if ( ! empty( $recipients ) ) { 75 return $recipients; 76 } 77 78 return [ '{{user.user_email}}' ]; 64 79 } 65 80 -
juvo-mail-editor/tags/3.0.5/src/Mails/Password_Changed_Admin.php
r2655718 r2672700 24 24 } 25 25 26 public function getSubject(): string { 26 public function getSubject( string $subject ): string { 27 28 if ( ! empty( $subject ) ) { 29 return $subject; 30 } 31 27 32 return sprintf( __( '%s Password Changed', 'default' ), '{{site.name}}' ); 28 33 } 29 34 30 public function getMessage(): string { 35 public function getMessage( string $message ): string { 36 37 if ( ! empty( $message ) ) { 38 return $message; 39 } 40 31 41 return sprintf( __( 'Password changed for user: %s', 'default' ), '{{user.name}}' ) . "\r\n"; 32 42 } 33 43 34 public function getRecipient(): string { 35 return '{{site.admin_email}}'; 44 public function getRecipients( array $recipients ): array { 45 46 if ( ! empty( $recipients ) ) { 47 return $recipients; 48 } 49 50 return [ '{{site.admin_email}}' ]; 36 51 } 37 52 38 53 public function prepareSend( array $email, WP_User $user ): array { 39 54 do_action( "juvo_mail_editor_send", $this->getTrigger(), [ "user" => $user ] ); 55 40 56 return $this->emptyMailArray( $email ); 41 57 } -
juvo-mail-editor/tags/3.0.5/src/Mails/Password_Reset.php
r2655718 r2672700 26 26 public function prepareSend( $message, string $key, $user_login, WP_User $user ): string { 27 27 do_action( "juvo_mail_editor_send", $this->getTrigger(), [ "user" => $user, 'key' => $key ] ); 28 28 29 return ''; 29 30 } 30 31 31 public function getSubject(): string { 32 public function getSubject( string $subject ): string { 33 34 if ( ! empty( $subject ) ) { 35 return $subject; 36 } 37 32 38 return __( 'Password Reset', 'juvo-mail-editor' ); 33 39 } 34 40 35 public function getMessage(): string { 41 public function getMessage( string $message ): string { 42 43 if ( ! empty( $message ) ) { 44 return $message; 45 } 46 36 47 $message = __( 'Someone has requested a password reset for the following account:', 'default' ) . "\r\n\r\n"; 37 48 $message .= sprintf( __( 'Site Name: %s', 'default' ), '{{ site.name }}' ) . "\r\n\r\n"; … … 44 55 } 45 56 46 public function getRecipient(): string { 47 return '{{ user.user_email }}'; 57 public function getRecipients( array $recipients ): array { 58 59 if ( ! empty( $recipients ) ) { 60 return $recipients; 61 } 62 63 return [ '{{user.user_email}}' ]; 48 64 } 49 65 -
juvo-mail-editor/tags/3.0.5/src/Mails/Password_Reset_Admin.php
r2655718 r2672700 14 14 } 15 15 16 public function getSubject(): string { 16 public function getSubject( string $subject ): string { 17 18 if ( ! empty( $subject ) ) { 19 return $subject; 20 } 21 17 22 return __( 'Password Reset (Admin)', 'juvo-mail-editor' ); 18 23 } 19 24 20 public function getMessage(): string { 25 public function getMessage( string $message ): string { 26 27 if ( ! empty( $message ) ) { 28 return $message; 29 } 30 21 31 $message = __( 'Someone has requested a password reset for the following account:', 'default' ) . "\r\n\r\n"; 22 32 $message .= sprintf( __( 'Site Name: %s', 'default' ), '{{ site.name}}' ) . "\r\n\r\n"; … … 26 36 } 27 37 28 public function getRecipient(): string { 29 return '{{ site.admin_email}}'; 38 public function getRecipients( array $recipients ): array { 39 40 if ( ! empty( $recipients ) ) { 41 return $recipients; 42 } 43 44 return [ '{{site.admin_email}}' ]; 30 45 } 31 46 32 47 public function prepareSend( $message, $key, $user_login, WP_User $user ): string { 33 48 do_action( "juvo_mail_editor_send", $this->getTrigger(), [ "user" => $user, 'key' => $key ] ); 49 34 50 return ''; 35 51 } -
juvo-mail-editor/tags/3.0.5/src/Mails_PT.php
r2655718 r2672700 84 84 $cmb->add_field( 85 85 array( 86 'name' => __( 'Recipients', 'juvo-mail-editor' ),87 'desc' => __( 'Comma seperated list of mail addresses', 'juvo-mail-editor' ),88 'id' => self::POST_TYPE_NAME . '_recipients',89 'type' => 'text',90 'column' => true,91 )92 );93 94 $cmb->add_field(95 array(96 86 'name' => __( 'Subject', 'juvo-mail-editor' ), 97 87 'desc' => __( 'E-Mail subject', 'juvo-mail-editor' ), … … 102 92 ); 103 93 94 $cmb->add_field( 95 array( 96 'name' => __( 'Recipients', 'juvo-mail-editor' ), 97 'id' => self::POST_TYPE_NAME . '_recipients', 98 'type' => 'text', 99 'column' => true, 100 ) 101 ); 102 103 $recipient_group = $cmb->add_field( array( 104 'id' => self::POST_TYPE_NAME . '_recipients', 105 'type' => 'group', 106 'description' => __( 'Comma seperated list of mail addresses', 'juvo-mail-editor' ), 107 'options' => array( 108 'group_title' => __( 'Recipient {#}', 'cmb2' ), 109 'add_button' => __( 'Add Another Entry', 'cmb2' ), 110 'remove_button' => __( 'Remove Entry', 'cmb2' ), 111 'sortable' => true, 112 'closed' => true, 113 'remove_confirm' => esc_html__( 'Are you sure you want to remove?', 'cmb2' ), 114 ), 115 'classes' => "cmb-flex" 116 ) ); 117 118 $this->addRecipientGroupFields( $recipient_group, $cmb ); 119 120 $cc_group = $cmb->add_field( array( 121 'id' => self::POST_TYPE_NAME . '_cc', 122 'type' => 'group', 123 'description' => __( 'Add recipients that should receive a carbon copy (CC). CC Recipients are visible in emails', 'juvo-mail-editor' ), 124 'options' => array( 125 'group_title' => __( 'CC Recipient {#}', 'cmb2' ), 126 'add_button' => __( 'Add Another Entry', 'cmb2' ), 127 'remove_button' => __( 'Remove Entry', 'cmb2' ), 128 'sortable' => true, 129 'closed' => true, 130 'remove_confirm' => esc_html__( 'Are you sure you want to remove?', 'cmb2' ), 131 ), 132 'classes' => "cmb-flex" 133 ) ); 134 135 $this->addRecipientGroupFields( $cc_group, $cmb ); 136 137 $bcc_group = $cmb->add_field( array( 138 'id' => self::POST_TYPE_NAME . '_bcc', 139 'type' => 'group', 140 'description' => __( 'Add recipients that should receive a “blind carbon copy.” Behaves like CC but without revealing the recipients in the email.', 'juvo-mail-editor' ), 141 'options' => array( 142 'group_title' => __( 'BCC Recipient {#}', 'cmb2' ), 143 'add_button' => __( 'Add Another Entry', 'cmb2' ), 144 'remove_button' => __( 'Remove Entry', 'cmb2' ), 145 'sortable' => true, 146 'closed' => true, 147 'remove_confirm' => esc_html__( 'Are you sure you want to remove?', 'cmb2' ), 148 ), 149 'classes' => "cmb-flex" 150 ) ); 151 152 $this->addRecipientGroupFields( $bcc_group, $cmb ); 153 154 155 $cmb->add_field( array( 156 'name' => __( 'Attachments', 'juvo-mail-editor' ), 157 'desc' => '', 158 'id' => self::POST_TYPE_NAME . '_attachments', 159 'type' => 'file_list', 160 ) ); 161 104 162 apply_filters( 'juvo_mail_editor_post_metabox', $cmb ); 105 163 } 106 164 165 private function addRecipientGroupFields( string $group, $cmb ) { 166 $cmb->add_group_field( $group, array( 167 'name' => __( 'Name', 'juvo-mail-editor' ), 168 'id' => 'name', 169 'type' => 'text', 170 'classes' => "flex-col-2" 171 ) ); 172 173 $cmb->add_group_field( $group, array( 174 'name' => __( 'Mail', 'juvo-mail-editor' ), 175 'id' => 'mail', 176 'type' => 'text', 177 'classes' => "flex-col-2", 178 'attributes' => array( 179 'data-validation' => 'required', 180 ), 181 ) ); 182 } 183 107 184 } -
juvo-mail-editor/tags/3.0.5/src/Relay.php
r2665461 r2672700 133 133 $headers = $relay->prepareHeaders( $post ); 134 134 135 // Attachments 136 $attachments = $relay->prepareAttachments( $post ); 137 135 138 // Restore language context 136 139 if ( $switched_locale ) { … … 138 141 } 139 142 140 $mail = new Generic( $subject, $content, $recipients, $headers );143 $mail = new Generic( $subject, $content, $recipients, $headers, $attachments ); 141 144 $mail->send(); 142 145 … … 156 159 157 160 // Fallback if not posts are found for configured trigger 158 $content = $relay->prepareContent(); 159 $subject = $relay->prepareSubject(); 160 $recipients = $relay->prepareRecipients(); 161 $headers = $relay->prepareHeaders(); 161 $content = $relay->prepareContent(); 162 $subject = $relay->prepareSubject(); 163 $recipients = $relay->prepareRecipients(); 164 $headers = $relay->prepareHeaders(); 165 $attachments = $relay->prepareAttachments(); 162 166 163 167 if ( $switched_locale ) { … … 165 169 } 166 170 167 $mail = new Generic( $subject, $content, $recipients, $headers );171 $mail = new Generic( $subject, $content, $recipients, $headers, $attachments ); 168 172 $mail->send(); 169 173 … … 194 198 * @param WP_Post|null $post 195 199 * 200 * @return array 201 */ 202 public function prepareRecipients( WP_Post $post = null ): array { 203 204 $recipients = []; 205 206 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 207 if ( $post ) { 208 $recipients = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_recipients', true ); 209 } 210 211 $recipients = apply_filters( "juvo_mail_editor_{$this->trigger}_recipients", $this->parseToCcBcc( $recipients ), $this->context ); 212 213 return apply_filters( 'juvo_mail_editor_after_recipient_placeholder', $recipients, $this->trigger, $this->context ); 214 } 215 216 /** 217 * @param WP_Post|null $post 218 * 196 219 * @return string 197 220 */ 198 public function prepareRecipients( WP_Post $post = null ): string {199 200 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure201 if ( ! $post || ! $recipients = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_recipients', true ) ) {202 $recipients = apply_filters( "juvo_mail_editor_{$this->trigger}_default_recipients", '', $this->context );203 }204 205 $recipients = apply_filters( 'juvo_mail_editor_before_recipient_placeholder', $recipients, $this->trigger, $this->context );206 $recipients = Placeholder::replacePlaceholder( $this->placeholders, $recipients, $this->context );207 208 return apply_filters( 'juvo_mail_editor_after_recipient_placeholder', $recipients, $this->trigger, $this->context );209 }210 211 /**212 * @param WP_Post|null $post213 *214 * @return string215 */216 221 public function prepareContent( WP_Post $post = null ): string { 217 222 218 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure219 if ( ! $post || ! $content = get_the_content( null, false, $post ) ) { 220 $content = apply_filters( "juvo_mail_editor_{$this->trigger}_message", '', $this->context );221 } else{223 $content = ''; 224 225 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 226 if ( $post && $content = get_the_content( null, false, $post ) ) { 222 227 $blocks = parse_blocks( $content ); 223 228 $content = ''; … … 228 233 } 229 234 230 $content = apply_filters( 'juvo_mail_editor_before_content_placeholder', $content, $this->trigger, $this->context );235 $content = apply_filters( "juvo_mail_editor_{$this->trigger}_message", $content, $this->context ); 231 236 $content = Placeholder::replacePlaceholder( $this->placeholders, $content, $this->context ); 232 237 $content = apply_filters( 'juvo_mail_editor_after_content_placeholder', $content, $this->trigger, $this->context ); … … 260 265 public function prepareSubject( WP_Post $post = null ): string { 261 266 262 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 263 if ( ! $post || ! $subject = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_subject', true ) ) { 264 $subject = apply_filters( "juvo_mail_editor_{$this->trigger}_subject", '', $this->context ); 265 } 266 267 $subject = apply_filters( 'juvo_mail_editor_before_subject_placeholder', $subject, $this->trigger, $this->context ); 267 $subject = ''; 268 269 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 270 if ( $post ) { 271 $subject = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_subject', true ); 272 } 273 274 $subject = apply_filters( "juvo_mail_editor_{$this->trigger}_subject", $subject, $this->context ); 268 275 $subject = Placeholder::replacePlaceholder( $this->placeholders, $subject, $this->context ); 269 276 … … 308 315 } 309 316 317 // Add CC and BCC 318 $headers = $this->prepareCc( $headers, $post ); 319 $headers = $this->prepareBcc( $headers, $post ); 320 310 321 return apply_filters( "juvo_mail_editor_{$this->trigger}_headers", $headers, $this->context ); 311 322 } 312 323 324 private function prepareAttachments( WP_Post $post = null ): array { 325 326 $attachments = []; 327 328 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 329 if ( $post ) { 330 $attachments = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_attachments', true ) ?: []; 331 332 if ( empty( $attachments ) ) { 333 return $attachments; 334 } 335 336 foreach ( $attachments as $id => &$attachment ) { 337 $attachment = get_attached_file( $id ); 338 } 339 } 340 341 return apply_filters( "juvo_mail_editor_{$this->trigger}_attachments", $attachments, $this->context ); 342 } 343 344 private function prepareCc( array $headers, WP_Post $post = null ): array { 345 346 $cc = []; 347 348 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 349 if ( $post ) { 350 $cc = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_cc', true ); 351 } 352 353 $cc = apply_filters( "juvo_mail_editor_{$this->trigger}_cc", $this->parseToCcBcc( $cc, "Cc:" ), $this->context ); 354 $cc = apply_filters( 'juvo_mail_editor_after_cc_placeholder', $cc, $this->trigger, $this->context ); 355 356 return array_merge( $headers, $cc ); 357 } 358 359 private function prepareBcc( array $headers, WP_Post $post = null ): array { 360 361 $bcc = []; 362 363 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 364 if ( $post ) { 365 $bcc = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_bcc', true ); 366 } 367 368 $bcc = apply_filters( "juvo_mail_editor_{$this->trigger}_bcc", $this->parseToCcBcc( $bcc, "Bcc:" ), $this->context ); 369 $bcc = apply_filters( 'juvo_mail_editor_after_bcc_placeholder', $bcc, $this->trigger, $this->context ); 370 371 return array_merge( $headers, $bcc ); 372 } 373 374 /** 375 * Parses cmb2 repeater groups or strings to wp_mail compatible array format for "to", "cc" and "bcc" 376 * 377 * @param array|string $recipients 378 * @param string $prefix "Cc:" or "Bcc:" 379 * 380 * @return array 381 */ 382 private function parseToCcBcc( $recipients, string $prefix = "" ): array { 383 384 if ( empty( $recipients ) ) { 385 return []; 386 } 387 388 if ( is_string( $recipients ) ) { 389 $recipients = explode( ",", $recipients ); 390 } 391 392 foreach ( $recipients as &$recipient ) { 393 394 if ( ! empty( $recipient['name'] ) && ! empty( $recipient['mail'] ) ) { 395 $recipient = "{$recipient['name']} <{$recipient['mail']}>"; 396 } elseif ( empty( $recipient['name'] ) && ! empty( $recipient['mail'] ) ) { 397 $recipient = $recipient['mail']; 398 } 399 400 $recipient = Placeholder::replacePlaceholder( $this->placeholders, $recipient, $this->context ); 401 402 if ( ! empty( $prefix ) ) { 403 $recipient = $prefix . " " . $recipient; 404 } 405 } 406 407 return $recipients; 408 409 } 410 313 411 } -
juvo-mail-editor/tags/3.0.5/vendor/autoload.php
r2665461 r2672700 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit df996d0981a8b06c2981bee783fc4f04::getLoader();7 return ComposerAutoloaderInitfdfdf11997bf846c7668e97b172e1c1f::getLoader(); -
juvo-mail-editor/tags/3.0.5/vendor/composer/autoload_real.php
r2665461 r2672700 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit df996d0981a8b06c2981bee783fc4f045 class ComposerAutoloaderInitfdfdf11997bf846c7668e97b172e1c1f 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit df996d0981a8b06c2981bee783fc4f04', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInitfdfdf11997bf846c7668e97b172e1c1f', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); 27 spl_autoload_unregister(array('ComposerAutoloaderInit df996d0981a8b06c2981bee783fc4f04', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInitfdfdf11997bf846c7668e97b172e1c1f', 'loadClassLoader')); 28 28 29 29 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 31 31 require __DIR__ . '/autoload_static.php'; 32 32 33 call_user_func(\Composer\Autoload\ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::getInitializer($loader));33 call_user_func(\Composer\Autoload\ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::getInitializer($loader)); 34 34 } else { 35 35 $map = require __DIR__ . '/autoload_namespaces.php'; … … 52 52 53 53 if ($useStaticLoader) { 54 $includeFiles = Composer\Autoload\ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$files;54 $includeFiles = Composer\Autoload\ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$files; 55 55 } else { 56 56 $includeFiles = require __DIR__ . '/autoload_files.php'; 57 57 } 58 58 foreach ($includeFiles as $fileIdentifier => $file) { 59 composerRequire df996d0981a8b06c2981bee783fc4f04($fileIdentifier, $file);59 composerRequirefdfdf11997bf846c7668e97b172e1c1f($fileIdentifier, $file); 60 60 } 61 61 … … 69 69 * @return void 70 70 */ 71 function composerRequire df996d0981a8b06c2981bee783fc4f04($fileIdentifier, $file)71 function composerRequirefdfdf11997bf846c7668e97b172e1c1f($fileIdentifier, $file) 72 72 { 73 73 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
juvo-mail-editor/tags/3.0.5/vendor/composer/autoload_static.php
r2665461 r2672700 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit df996d0981a8b06c2981bee783fc4f047 class ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f 8 8 { 9 9 public static $files = array ( … … 94 94 { 95 95 return \Closure::bind(function () use ($loader) { 96 $loader->prefixLengthsPsr4 = ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$prefixLengthsPsr4;97 $loader->prefixDirsPsr4 = ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$prefixDirsPsr4;98 $loader->fallbackDirsPsr4 = ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$fallbackDirsPsr4;99 $loader->prefixesPsr0 = ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$prefixesPsr0;100 $loader->classMap = ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$classMap;96 $loader->prefixLengthsPsr4 = ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$prefixLengthsPsr4; 97 $loader->prefixDirsPsr4 = ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$prefixDirsPsr4; 98 $loader->fallbackDirsPsr4 = ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$fallbackDirsPsr4; 99 $loader->prefixesPsr0 = ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$prefixesPsr0; 100 $loader->classMap = ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$classMap; 101 101 102 102 }, null, ClassLoader::class); -
juvo-mail-editor/tags/3.0.5/vendor/composer/installed.php
r2665461 r2672700 1 1 <?php return array( 2 2 'root' => array( 3 'pretty_version' => '3.0. 4',4 'version' => '3.0. 4.0',3 'pretty_version' => '3.0.5', 4 'version' => '3.0.5.0', 5 5 'type' => 'wordpress-plugin', 6 6 'install_path' => __DIR__ . '/../../', 7 7 'aliases' => array(), 8 'reference' => ' 2d251ec3164a7834e1949b59ad82a1c12336148d',8 'reference' => '78ed8db8c7bf3e36838fbdeedd047527631aec6d', 9 9 'name' => 'juvo/mail-editor', 10 10 'dev' => false, … … 39 39 ), 40 40 'juvo/mail-editor' => array( 41 'pretty_version' => '3.0. 4',42 'version' => '3.0. 4.0',41 'pretty_version' => '3.0.5', 42 'version' => '3.0.5.0', 43 43 'type' => 'wordpress-plugin', 44 44 'install_path' => __DIR__ . '/../../', 45 45 'aliases' => array(), 46 'reference' => ' 2d251ec3164a7834e1949b59ad82a1c12336148d',46 'reference' => '78ed8db8c7bf3e36838fbdeedd047527631aec6d', 47 47 'dev_requirement' => false, 48 48 ), -
juvo-mail-editor/trunk/juvo-mail-editor.php
r2665461 r2672700 8 8 * Text Domain: juvo-mail-editor 9 9 * Domain Path: /languages 10 * Version: 3.0. 410 * Version: 3.0.5 11 11 */ 12 12 -
juvo-mail-editor/trunk/readme.txt
r2665461 r2672700 4 4 License: GPLv2 or later 5 5 Tested up to: 5.9 6 Stable tag: 3.0. 46 Stable tag: 3.0.5 7 7 8 8 JUVO Mail Editor helps to modify the standard WordPress Mailings and allows adding dynamic mail triggers. … … 22 22 * Seamless integration to any mail styling plugin - even buddyboss. 23 23 * Multilanguage support 24 * Set CC, BCC and Attachments for mails 24 25 25 26 == Frequently Asked Questions == -
juvo-mail-editor/trunk/src/Mail_Generator.php
r2655718 r2672700 14 14 add_filter( 'juvo_mail_editor_trigger', array( $this, 'registerTrigger' ) ); 15 15 16 add_filter( "juvo_mail_editor_{$this->getTrigger()}_always_sent", array( $this, 'getAlwaysSent' ), 1 , 0 );17 add_filter( "juvo_mail_editor_{$this->getTrigger()}_subject", array( $this, 'getSubject' ), 1 , 0);18 add_filter( "juvo_mail_editor_{$this->getTrigger()}_message", array( $this, 'getMessage' ), 1 , 0);19 add_filter( "juvo_mail_editor_{$this->getTrigger()}_ default_recipients", array( $this, 'getRecipient' ), 1, 0);16 add_filter( "juvo_mail_editor_{$this->getTrigger()}_always_sent", array( $this, 'getAlwaysSent' ), 10, 0 ); 17 add_filter( "juvo_mail_editor_{$this->getTrigger()}_subject", array( $this, 'getSubject' ), 10, 1 ); 18 add_filter( "juvo_mail_editor_{$this->getTrigger()}_message", array( $this, 'getMessage' ), 10, 1 ); 19 add_filter( "juvo_mail_editor_{$this->getTrigger()}_recipients", array( $this, 'getRecipients' ), 10, 1 ); 20 20 add_filter( 21 21 "juvo_mail_editor_{$this->getTrigger()}_placeholders", -
juvo-mail-editor/trunk/src/Mails/Generic.php
r2665450 r2672700 10 10 private $recipients; 11 11 private $headers; 12 private $attachments; 12 13 13 14 /** … … 16 17 * @param string $subject 17 18 * @param string $content 18 * @param string $recipients 19 * @param array $recipients 20 * @param array $headers 21 * @param array $attachments 19 22 */ 20 public function __construct( string $subject, string $content, string $recipients, array $headers ) { 21 $this->subject = $subject; 22 $this->content = $content; 23 $this->recipients = $recipients; 24 $this->headers = $headers; 23 public function __construct( string $subject, string $content, array $recipients, array $headers, array $attachments ) { 24 $this->subject = $subject; 25 $this->content = $content; 26 $this->recipients = $recipients; 27 $this->headers = $headers; 28 $this->attachments = $attachments; 25 29 } 26 30 … … 29 33 */ 30 34 public function send() { 31 return wp_mail( $this->recipients, $this->subject, $this->content, $this->headers );35 return wp_mail( $this->recipients, $this->subject, $this->content, $this->headers, $this->attachments ); 32 36 } 33 37 } -
juvo-mail-editor/trunk/src/Mails/Mail.php
r2655718 r2672700 5 5 interface Mail { 6 6 7 public function getSubject( ): string;7 public function getSubject( string $subject ): string; 8 8 9 public function getMessage( ): string;9 public function getMessage( string $message ): string; 10 10 11 public function getRecipient (): string;11 public function getRecipients( array $recipients ): array; 12 12 13 13 public function getAlwaysSent(): bool; -
juvo-mail-editor/trunk/src/Mails/New_User.php
r2655718 r2672700 39 39 } 40 40 41 public function getSubject(): string { 41 public function getSubject( string $subject ): string { 42 43 if ( ! empty( $subject ) ) { 44 return $subject; 45 } 46 42 47 return sprintf( __( '%s Login Details', 'default' ), '{{site.name}}' ); 43 48 } 44 49 45 public function getMessage(): string { 50 public function getMessage( string $message ): string { 51 52 if ( ! empty( $message ) ) { 53 return $message; 54 } 55 46 56 $message = sprintf( __( 'Username: %s', 'default' ), '{{user.name}}' ) . "\r\n\r\n"; 47 57 $message .= __( 'To set your password, visit the following address:', 'default' ) . "\r\n\r\n"; … … 51 61 } 52 62 53 public function getRecipient(): string { 54 return '{{user.user_email}}'; 63 public function getRecipients( array $recipients ): array { 64 65 if ( ! empty( $recipients ) ) { 66 return $recipients; 67 } 68 69 return [ '{{user.user_email}}' ]; 55 70 } 56 71 -
juvo-mail-editor/trunk/src/Mails/New_User_Admin.php
r2655718 r2672700 17 17 public function prepareSend( array $email, WP_User $user ): array { 18 18 do_action( "juvo_mail_editor_send", $this->getTrigger(), [ "user" => $user ] ); 19 19 20 return $this->emptyMailArray( $email ); 20 21 } 21 22 22 public function getSubject(): string { 23 public function getSubject( string $subject ): string { 24 25 if ( ! empty( $subject ) ) { 26 return $subject; 27 } 28 23 29 return sprintf( __( '[%s] New User Registration', 'default' ), '{{site.name}}' ); 24 30 } 25 31 26 public function getMessage(): string { 32 public function getMessage( string $message ): string { 33 34 if ( ! empty( $message ) ) { 35 return $message; 36 } 37 27 38 $message = sprintf( __( 'New user registration on your site %s:', 'default' ), '{{site.name}}' ) . "\r\n\r\n"; 28 39 $message .= sprintf( __( 'Username: %s', 'default' ), '{{user.name}}' ) . "\r\n\r\n"; … … 32 43 } 33 44 34 public function getRecipient(): string { 35 return '{{site.admin_email}}'; 45 public function getRecipients( array $recipients ): array { 46 47 if ( ! empty( $recipients ) ) { 48 return $recipients; 49 } 50 51 return [ '{{site.admin_email}}' ]; 36 52 } 37 53 -
juvo-mail-editor/trunk/src/Mails/New_User_Admin_Rest.php
r2655718 r2672700 19 19 } 20 20 21 public function getSubject(): string { 21 public function getSubject( string $subject ): string { 22 23 if ( ! empty( $subject ) ) { 24 return $subject; 25 } 26 22 27 return sprintf( __( '[%s] New User Registration', 'default' ), '{{site.name}}' ); 23 28 } 24 29 25 public function getMessage(): string { 30 public function getMessage( string $message ): string { 31 32 if ( ! empty( $message ) ) { 33 return $message; 34 } 35 26 36 $message = sprintf( __( 'New user registration on your site %s:', 'default' ), '{{site.name}}' ) . "\r\n\r\n"; 27 37 $message .= sprintf( __( 'Username: %s', 'default' ), '{{user.name}}' ) . "\r\n\r\n"; … … 31 41 } 32 42 33 public function getRecipient(): string { 34 return '{{site.admin_email}}'; 43 public function getRecipients( array $recipients ): array { 44 45 if ( ! empty( $recipients ) ) { 46 return $recipients; 47 } 48 49 return [ '{{site.admin_email}}' ]; 35 50 } 36 51 -
juvo-mail-editor/trunk/src/Mails/New_User_Rest.php
r2655718 r2672700 46 46 } 47 47 48 public function getSubject(): string { 48 public function getSubject( string $subject ): string { 49 50 if ( ! empty( $subject ) ) { 51 return $subject; 52 } 53 49 54 return sprintf( __( '%s Login Details', 'default' ), '{{site.name}}' ); 50 55 } 51 56 52 public function getMessage(): string { 57 public function getMessage( string $message ): string { 58 59 if ( ! empty( $message ) ) { 60 return $message; 61 } 62 53 63 $message = sprintf( __( 'Username: %s', 'default' ), '{{user.name}}' ) . "\r\n\r\n"; 54 64 $message .= __( 'To set your password, visit the following address:', 'default' ) . "\r\n\r\n"; … … 58 68 } 59 69 60 public function getRecipient(): string { 61 return '{{user.user_email}}'; 70 public function getRecipients( array $recipients ): array { 71 72 if ( ! empty( $recipients ) ) { 73 return $recipients; 74 } 75 76 return [ '{{user.user_email}}' ]; 62 77 } 63 78 -
juvo-mail-editor/trunk/src/Mails/Password_Changed.php
r2655718 r2672700 24 24 } 25 25 26 public function getSubject(): string { 26 public function getSubject( string $subject ): string { 27 28 if ( ! empty( $subject ) ) { 29 return $subject; 30 } 31 27 32 return sprintf( __( '%s Password Changed', 'default' ), '{{site.name}}' ); 28 33 } 29 34 30 public function getMessage(): string { 35 public function getMessage( string $message ): string { 36 37 if ( ! empty( $message ) ) { 38 return $message; 39 } 40 31 41 $message = __( 32 42 'Hi ###USERNAME###, … … 60 70 } 61 71 62 public function getRecipient(): string { 63 return '{{user.user_email}}'; 72 public function getRecipients( array $recipients ): array { 73 74 if ( ! empty( $recipients ) ) { 75 return $recipients; 76 } 77 78 return [ '{{user.user_email}}' ]; 64 79 } 65 80 -
juvo-mail-editor/trunk/src/Mails/Password_Changed_Admin.php
r2655718 r2672700 24 24 } 25 25 26 public function getSubject(): string { 26 public function getSubject( string $subject ): string { 27 28 if ( ! empty( $subject ) ) { 29 return $subject; 30 } 31 27 32 return sprintf( __( '%s Password Changed', 'default' ), '{{site.name}}' ); 28 33 } 29 34 30 public function getMessage(): string { 35 public function getMessage( string $message ): string { 36 37 if ( ! empty( $message ) ) { 38 return $message; 39 } 40 31 41 return sprintf( __( 'Password changed for user: %s', 'default' ), '{{user.name}}' ) . "\r\n"; 32 42 } 33 43 34 public function getRecipient(): string { 35 return '{{site.admin_email}}'; 44 public function getRecipients( array $recipients ): array { 45 46 if ( ! empty( $recipients ) ) { 47 return $recipients; 48 } 49 50 return [ '{{site.admin_email}}' ]; 36 51 } 37 52 38 53 public function prepareSend( array $email, WP_User $user ): array { 39 54 do_action( "juvo_mail_editor_send", $this->getTrigger(), [ "user" => $user ] ); 55 40 56 return $this->emptyMailArray( $email ); 41 57 } -
juvo-mail-editor/trunk/src/Mails/Password_Reset.php
r2655718 r2672700 26 26 public function prepareSend( $message, string $key, $user_login, WP_User $user ): string { 27 27 do_action( "juvo_mail_editor_send", $this->getTrigger(), [ "user" => $user, 'key' => $key ] ); 28 28 29 return ''; 29 30 } 30 31 31 public function getSubject(): string { 32 public function getSubject( string $subject ): string { 33 34 if ( ! empty( $subject ) ) { 35 return $subject; 36 } 37 32 38 return __( 'Password Reset', 'juvo-mail-editor' ); 33 39 } 34 40 35 public function getMessage(): string { 41 public function getMessage( string $message ): string { 42 43 if ( ! empty( $message ) ) { 44 return $message; 45 } 46 36 47 $message = __( 'Someone has requested a password reset for the following account:', 'default' ) . "\r\n\r\n"; 37 48 $message .= sprintf( __( 'Site Name: %s', 'default' ), '{{ site.name }}' ) . "\r\n\r\n"; … … 44 55 } 45 56 46 public function getRecipient(): string { 47 return '{{ user.user_email }}'; 57 public function getRecipients( array $recipients ): array { 58 59 if ( ! empty( $recipients ) ) { 60 return $recipients; 61 } 62 63 return [ '{{user.user_email}}' ]; 48 64 } 49 65 -
juvo-mail-editor/trunk/src/Mails/Password_Reset_Admin.php
r2655718 r2672700 14 14 } 15 15 16 public function getSubject(): string { 16 public function getSubject( string $subject ): string { 17 18 if ( ! empty( $subject ) ) { 19 return $subject; 20 } 21 17 22 return __( 'Password Reset (Admin)', 'juvo-mail-editor' ); 18 23 } 19 24 20 public function getMessage(): string { 25 public function getMessage( string $message ): string { 26 27 if ( ! empty( $message ) ) { 28 return $message; 29 } 30 21 31 $message = __( 'Someone has requested a password reset for the following account:', 'default' ) . "\r\n\r\n"; 22 32 $message .= sprintf( __( 'Site Name: %s', 'default' ), '{{ site.name}}' ) . "\r\n\r\n"; … … 26 36 } 27 37 28 public function getRecipient(): string { 29 return '{{ site.admin_email}}'; 38 public function getRecipients( array $recipients ): array { 39 40 if ( ! empty( $recipients ) ) { 41 return $recipients; 42 } 43 44 return [ '{{site.admin_email}}' ]; 30 45 } 31 46 32 47 public function prepareSend( $message, $key, $user_login, WP_User $user ): string { 33 48 do_action( "juvo_mail_editor_send", $this->getTrigger(), [ "user" => $user, 'key' => $key ] ); 49 34 50 return ''; 35 51 } -
juvo-mail-editor/trunk/src/Mails_PT.php
r2655718 r2672700 84 84 $cmb->add_field( 85 85 array( 86 'name' => __( 'Recipients', 'juvo-mail-editor' ),87 'desc' => __( 'Comma seperated list of mail addresses', 'juvo-mail-editor' ),88 'id' => self::POST_TYPE_NAME . '_recipients',89 'type' => 'text',90 'column' => true,91 )92 );93 94 $cmb->add_field(95 array(96 86 'name' => __( 'Subject', 'juvo-mail-editor' ), 97 87 'desc' => __( 'E-Mail subject', 'juvo-mail-editor' ), … … 102 92 ); 103 93 94 $cmb->add_field( 95 array( 96 'name' => __( 'Recipients', 'juvo-mail-editor' ), 97 'id' => self::POST_TYPE_NAME . '_recipients', 98 'type' => 'text', 99 'column' => true, 100 ) 101 ); 102 103 $recipient_group = $cmb->add_field( array( 104 'id' => self::POST_TYPE_NAME . '_recipients', 105 'type' => 'group', 106 'description' => __( 'Comma seperated list of mail addresses', 'juvo-mail-editor' ), 107 'options' => array( 108 'group_title' => __( 'Recipient {#}', 'cmb2' ), 109 'add_button' => __( 'Add Another Entry', 'cmb2' ), 110 'remove_button' => __( 'Remove Entry', 'cmb2' ), 111 'sortable' => true, 112 'closed' => true, 113 'remove_confirm' => esc_html__( 'Are you sure you want to remove?', 'cmb2' ), 114 ), 115 'classes' => "cmb-flex" 116 ) ); 117 118 $this->addRecipientGroupFields( $recipient_group, $cmb ); 119 120 $cc_group = $cmb->add_field( array( 121 'id' => self::POST_TYPE_NAME . '_cc', 122 'type' => 'group', 123 'description' => __( 'Add recipients that should receive a carbon copy (CC). CC Recipients are visible in emails', 'juvo-mail-editor' ), 124 'options' => array( 125 'group_title' => __( 'CC Recipient {#}', 'cmb2' ), 126 'add_button' => __( 'Add Another Entry', 'cmb2' ), 127 'remove_button' => __( 'Remove Entry', 'cmb2' ), 128 'sortable' => true, 129 'closed' => true, 130 'remove_confirm' => esc_html__( 'Are you sure you want to remove?', 'cmb2' ), 131 ), 132 'classes' => "cmb-flex" 133 ) ); 134 135 $this->addRecipientGroupFields( $cc_group, $cmb ); 136 137 $bcc_group = $cmb->add_field( array( 138 'id' => self::POST_TYPE_NAME . '_bcc', 139 'type' => 'group', 140 'description' => __( 'Add recipients that should receive a “blind carbon copy.” Behaves like CC but without revealing the recipients in the email.', 'juvo-mail-editor' ), 141 'options' => array( 142 'group_title' => __( 'BCC Recipient {#}', 'cmb2' ), 143 'add_button' => __( 'Add Another Entry', 'cmb2' ), 144 'remove_button' => __( 'Remove Entry', 'cmb2' ), 145 'sortable' => true, 146 'closed' => true, 147 'remove_confirm' => esc_html__( 'Are you sure you want to remove?', 'cmb2' ), 148 ), 149 'classes' => "cmb-flex" 150 ) ); 151 152 $this->addRecipientGroupFields( $bcc_group, $cmb ); 153 154 155 $cmb->add_field( array( 156 'name' => __( 'Attachments', 'juvo-mail-editor' ), 157 'desc' => '', 158 'id' => self::POST_TYPE_NAME . '_attachments', 159 'type' => 'file_list', 160 ) ); 161 104 162 apply_filters( 'juvo_mail_editor_post_metabox', $cmb ); 105 163 } 106 164 165 private function addRecipientGroupFields( string $group, $cmb ) { 166 $cmb->add_group_field( $group, array( 167 'name' => __( 'Name', 'juvo-mail-editor' ), 168 'id' => 'name', 169 'type' => 'text', 170 'classes' => "flex-col-2" 171 ) ); 172 173 $cmb->add_group_field( $group, array( 174 'name' => __( 'Mail', 'juvo-mail-editor' ), 175 'id' => 'mail', 176 'type' => 'text', 177 'classes' => "flex-col-2", 178 'attributes' => array( 179 'data-validation' => 'required', 180 ), 181 ) ); 182 } 183 107 184 } -
juvo-mail-editor/trunk/src/Relay.php
r2665461 r2672700 133 133 $headers = $relay->prepareHeaders( $post ); 134 134 135 // Attachments 136 $attachments = $relay->prepareAttachments( $post ); 137 135 138 // Restore language context 136 139 if ( $switched_locale ) { … … 138 141 } 139 142 140 $mail = new Generic( $subject, $content, $recipients, $headers );143 $mail = new Generic( $subject, $content, $recipients, $headers, $attachments ); 141 144 $mail->send(); 142 145 … … 156 159 157 160 // Fallback if not posts are found for configured trigger 158 $content = $relay->prepareContent(); 159 $subject = $relay->prepareSubject(); 160 $recipients = $relay->prepareRecipients(); 161 $headers = $relay->prepareHeaders(); 161 $content = $relay->prepareContent(); 162 $subject = $relay->prepareSubject(); 163 $recipients = $relay->prepareRecipients(); 164 $headers = $relay->prepareHeaders(); 165 $attachments = $relay->prepareAttachments(); 162 166 163 167 if ( $switched_locale ) { … … 165 169 } 166 170 167 $mail = new Generic( $subject, $content, $recipients, $headers );171 $mail = new Generic( $subject, $content, $recipients, $headers, $attachments ); 168 172 $mail->send(); 169 173 … … 194 198 * @param WP_Post|null $post 195 199 * 200 * @return array 201 */ 202 public function prepareRecipients( WP_Post $post = null ): array { 203 204 $recipients = []; 205 206 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 207 if ( $post ) { 208 $recipients = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_recipients', true ); 209 } 210 211 $recipients = apply_filters( "juvo_mail_editor_{$this->trigger}_recipients", $this->parseToCcBcc( $recipients ), $this->context ); 212 213 return apply_filters( 'juvo_mail_editor_after_recipient_placeholder', $recipients, $this->trigger, $this->context ); 214 } 215 216 /** 217 * @param WP_Post|null $post 218 * 196 219 * @return string 197 220 */ 198 public function prepareRecipients( WP_Post $post = null ): string {199 200 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure201 if ( ! $post || ! $recipients = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_recipients', true ) ) {202 $recipients = apply_filters( "juvo_mail_editor_{$this->trigger}_default_recipients", '', $this->context );203 }204 205 $recipients = apply_filters( 'juvo_mail_editor_before_recipient_placeholder', $recipients, $this->trigger, $this->context );206 $recipients = Placeholder::replacePlaceholder( $this->placeholders, $recipients, $this->context );207 208 return apply_filters( 'juvo_mail_editor_after_recipient_placeholder', $recipients, $this->trigger, $this->context );209 }210 211 /**212 * @param WP_Post|null $post213 *214 * @return string215 */216 221 public function prepareContent( WP_Post $post = null ): string { 217 222 218 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure219 if ( ! $post || ! $content = get_the_content( null, false, $post ) ) { 220 $content = apply_filters( "juvo_mail_editor_{$this->trigger}_message", '', $this->context );221 } else{223 $content = ''; 224 225 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 226 if ( $post && $content = get_the_content( null, false, $post ) ) { 222 227 $blocks = parse_blocks( $content ); 223 228 $content = ''; … … 228 233 } 229 234 230 $content = apply_filters( 'juvo_mail_editor_before_content_placeholder', $content, $this->trigger, $this->context );235 $content = apply_filters( "juvo_mail_editor_{$this->trigger}_message", $content, $this->context ); 231 236 $content = Placeholder::replacePlaceholder( $this->placeholders, $content, $this->context ); 232 237 $content = apply_filters( 'juvo_mail_editor_after_content_placeholder', $content, $this->trigger, $this->context ); … … 260 265 public function prepareSubject( WP_Post $post = null ): string { 261 266 262 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 263 if ( ! $post || ! $subject = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_subject', true ) ) { 264 $subject = apply_filters( "juvo_mail_editor_{$this->trigger}_subject", '', $this->context ); 265 } 266 267 $subject = apply_filters( 'juvo_mail_editor_before_subject_placeholder', $subject, $this->trigger, $this->context ); 267 $subject = ''; 268 269 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 270 if ( $post ) { 271 $subject = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_subject', true ); 272 } 273 274 $subject = apply_filters( "juvo_mail_editor_{$this->trigger}_subject", $subject, $this->context ); 268 275 $subject = Placeholder::replacePlaceholder( $this->placeholders, $subject, $this->context ); 269 276 … … 308 315 } 309 316 317 // Add CC and BCC 318 $headers = $this->prepareCc( $headers, $post ); 319 $headers = $this->prepareBcc( $headers, $post ); 320 310 321 return apply_filters( "juvo_mail_editor_{$this->trigger}_headers", $headers, $this->context ); 311 322 } 312 323 324 private function prepareAttachments( WP_Post $post = null ): array { 325 326 $attachments = []; 327 328 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 329 if ( $post ) { 330 $attachments = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_attachments', true ) ?: []; 331 332 if ( empty( $attachments ) ) { 333 return $attachments; 334 } 335 336 foreach ( $attachments as $id => &$attachment ) { 337 $attachment = get_attached_file( $id ); 338 } 339 } 340 341 return apply_filters( "juvo_mail_editor_{$this->trigger}_attachments", $attachments, $this->context ); 342 } 343 344 private function prepareCc( array $headers, WP_Post $post = null ): array { 345 346 $cc = []; 347 348 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 349 if ( $post ) { 350 $cc = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_cc', true ); 351 } 352 353 $cc = apply_filters( "juvo_mail_editor_{$this->trigger}_cc", $this->parseToCcBcc( $cc, "Cc:" ), $this->context ); 354 $cc = apply_filters( 'juvo_mail_editor_after_cc_placeholder', $cc, $this->trigger, $this->context ); 355 356 return array_merge( $headers, $cc ); 357 } 358 359 private function prepareBcc( array $headers, WP_Post $post = null ): array { 360 361 $bcc = []; 362 363 // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure 364 if ( $post ) { 365 $bcc = get_post_meta( $post->ID, Mails_PT::POST_TYPE_NAME . '_bcc', true ); 366 } 367 368 $bcc = apply_filters( "juvo_mail_editor_{$this->trigger}_bcc", $this->parseToCcBcc( $bcc, "Bcc:" ), $this->context ); 369 $bcc = apply_filters( 'juvo_mail_editor_after_bcc_placeholder', $bcc, $this->trigger, $this->context ); 370 371 return array_merge( $headers, $bcc ); 372 } 373 374 /** 375 * Parses cmb2 repeater groups or strings to wp_mail compatible array format for "to", "cc" and "bcc" 376 * 377 * @param array|string $recipients 378 * @param string $prefix "Cc:" or "Bcc:" 379 * 380 * @return array 381 */ 382 private function parseToCcBcc( $recipients, string $prefix = "" ): array { 383 384 if ( empty( $recipients ) ) { 385 return []; 386 } 387 388 if ( is_string( $recipients ) ) { 389 $recipients = explode( ",", $recipients ); 390 } 391 392 foreach ( $recipients as &$recipient ) { 393 394 if ( ! empty( $recipient['name'] ) && ! empty( $recipient['mail'] ) ) { 395 $recipient = "{$recipient['name']} <{$recipient['mail']}>"; 396 } elseif ( empty( $recipient['name'] ) && ! empty( $recipient['mail'] ) ) { 397 $recipient = $recipient['mail']; 398 } 399 400 $recipient = Placeholder::replacePlaceholder( $this->placeholders, $recipient, $this->context ); 401 402 if ( ! empty( $prefix ) ) { 403 $recipient = $prefix . " " . $recipient; 404 } 405 } 406 407 return $recipients; 408 409 } 410 313 411 } -
juvo-mail-editor/trunk/vendor/autoload.php
r2665461 r2672700 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit df996d0981a8b06c2981bee783fc4f04::getLoader();7 return ComposerAutoloaderInitfdfdf11997bf846c7668e97b172e1c1f::getLoader(); -
juvo-mail-editor/trunk/vendor/composer/autoload_real.php
r2665461 r2672700 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit df996d0981a8b06c2981bee783fc4f045 class ComposerAutoloaderInitfdfdf11997bf846c7668e97b172e1c1f 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit df996d0981a8b06c2981bee783fc4f04', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInitfdfdf11997bf846c7668e97b172e1c1f', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); 27 spl_autoload_unregister(array('ComposerAutoloaderInit df996d0981a8b06c2981bee783fc4f04', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInitfdfdf11997bf846c7668e97b172e1c1f', 'loadClassLoader')); 28 28 29 29 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 31 31 require __DIR__ . '/autoload_static.php'; 32 32 33 call_user_func(\Composer\Autoload\ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::getInitializer($loader));33 call_user_func(\Composer\Autoload\ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::getInitializer($loader)); 34 34 } else { 35 35 $map = require __DIR__ . '/autoload_namespaces.php'; … … 52 52 53 53 if ($useStaticLoader) { 54 $includeFiles = Composer\Autoload\ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$files;54 $includeFiles = Composer\Autoload\ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$files; 55 55 } else { 56 56 $includeFiles = require __DIR__ . '/autoload_files.php'; 57 57 } 58 58 foreach ($includeFiles as $fileIdentifier => $file) { 59 composerRequire df996d0981a8b06c2981bee783fc4f04($fileIdentifier, $file);59 composerRequirefdfdf11997bf846c7668e97b172e1c1f($fileIdentifier, $file); 60 60 } 61 61 … … 69 69 * @return void 70 70 */ 71 function composerRequire df996d0981a8b06c2981bee783fc4f04($fileIdentifier, $file)71 function composerRequirefdfdf11997bf846c7668e97b172e1c1f($fileIdentifier, $file) 72 72 { 73 73 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
juvo-mail-editor/trunk/vendor/composer/autoload_static.php
r2665461 r2672700 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit df996d0981a8b06c2981bee783fc4f047 class ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f 8 8 { 9 9 public static $files = array ( … … 94 94 { 95 95 return \Closure::bind(function () use ($loader) { 96 $loader->prefixLengthsPsr4 = ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$prefixLengthsPsr4;97 $loader->prefixDirsPsr4 = ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$prefixDirsPsr4;98 $loader->fallbackDirsPsr4 = ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$fallbackDirsPsr4;99 $loader->prefixesPsr0 = ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$prefixesPsr0;100 $loader->classMap = ComposerStaticInit df996d0981a8b06c2981bee783fc4f04::$classMap;96 $loader->prefixLengthsPsr4 = ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$prefixLengthsPsr4; 97 $loader->prefixDirsPsr4 = ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$prefixDirsPsr4; 98 $loader->fallbackDirsPsr4 = ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$fallbackDirsPsr4; 99 $loader->prefixesPsr0 = ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$prefixesPsr0; 100 $loader->classMap = ComposerStaticInitfdfdf11997bf846c7668e97b172e1c1f::$classMap; 101 101 102 102 }, null, ClassLoader::class); -
juvo-mail-editor/trunk/vendor/composer/installed.php
r2665461 r2672700 1 1 <?php return array( 2 2 'root' => array( 3 'pretty_version' => '3.0. 4',4 'version' => '3.0. 4.0',3 'pretty_version' => '3.0.5', 4 'version' => '3.0.5.0', 5 5 'type' => 'wordpress-plugin', 6 6 'install_path' => __DIR__ . '/../../', 7 7 'aliases' => array(), 8 'reference' => ' 2d251ec3164a7834e1949b59ad82a1c12336148d',8 'reference' => '78ed8db8c7bf3e36838fbdeedd047527631aec6d', 9 9 'name' => 'juvo/mail-editor', 10 10 'dev' => false, … … 39 39 ), 40 40 'juvo/mail-editor' => array( 41 'pretty_version' => '3.0. 4',42 'version' => '3.0. 4.0',41 'pretty_version' => '3.0.5', 42 'version' => '3.0.5.0', 43 43 'type' => 'wordpress-plugin', 44 44 'install_path' => __DIR__ . '/../../', 45 45 'aliases' => array(), 46 'reference' => ' 2d251ec3164a7834e1949b59ad82a1c12336148d',46 'reference' => '78ed8db8c7bf3e36838fbdeedd047527631aec6d', 47 47 'dev_requirement' => false, 48 48 ),
Note: See TracChangeset
for help on using the changeset viewer.