Changeset 2280329
- Timestamp:
- 04/09/2020 03:22:50 PM (6 years ago)
- Location:
- cf7-db-tool
- Files:
-
- 2 added
- 5 edited
-
assets/screenshot-14.png (added)
-
trunk/assets/js/cf7-db-mail-provider.js (modified) (2 diffs)
-
trunk/cf7-db-tool.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/src/BulkMail.php (modified) (1 diff)
-
trunk/src/Plugin.php (modified) (7 diffs)
-
trunk/src/connected_mail/sendgrid.php (added)
Legend:
- Unmodified
- Added
- Removed
-
cf7-db-tool/trunk/assets/js/cf7-db-mail-provider.js
r2279382 r2280329 2 2 var MailgunInput = document.querySelectorAll(".mailgun-input"); 3 3 var SendGridInput = document.querySelectorAll(".sendgrid-input"); 4 var chooseMailer = document.querySelector("#choose-mailer"); 4 5 5 6 (function ($) { … … 7 8 $(document).ready(function(){ 8 9 9 10 $('#choose-mailer').on('change', function() { 11 12 var SelectedProvider = $(this).find(":selected").val(); 13 14 console.log(MailgunInput); 15 console.log(SendGridInput); 16 17 console.log(SelectedProvider); 18 19 if(SelectedProvider == 'Mailgun'){ 10 $('.active_mail_provider').on('change', function(){ 11 if(this.checked){ 12 chooseMailer.setAttribute('required','true'); 13 } 14 else{ 15 chooseMailer.removeAttribute('required'); 16 SendGridInput.forEach(function(sendGridFiled){ 17 sendGridFiled.removeAttribute('required'); 18 }); 19 MailgunInput.forEach(function(mailgunFiled){ 20 mailgunFiled.removeAttribute('required'); 21 }); 20 22 21 23 } 24 }); 25 26 $("#choose-mailer").on('change', function() { 27 28 var SelectedProvider = $(this).find(":selected").val().trim(); 29 if(SelectedProvider == 'Mailgun'){ 30 MailgunInput.forEach(function(mailgunFiled){ 31 mailgunFiled.setAttribute('required','true'); 32 }); 33 SendGridInput.forEach(function(sendGridFiled){ 34 sendGridFiled.removeAttribute('required'); 35 }); 36 } 22 37 if(SelectedProvider == 'SendGrid'){ 38 SendGridInput.forEach(function(sendGridFiled){ 39 sendGridFiled.setAttribute('required','true'); 40 }); 41 MailgunInput.forEach(function(mailgunFiled){ 42 mailgunFiled.removeAttribute('required'); 43 }); 23 44 24 45 } 25 26 27 28 46 }); 29 30 47 }); 31 48 })(jQuery); -
cf7-db-tool/trunk/cf7-db-tool.php
r2279382 r2280329 8 8 * Text Domain: cf7-db-tool 9 9 * Tags: contact, cf7, zapier, integration, webhook, bulk mail, contact form 7, db, export, save, wpcf7, contact form 7 db, contact form 7 database, contact form 7 data export, contact form 7 database addon 10 * Version: 4.2. 510 * Version: 4.2.6 11 11 */ 12 12 13 define('CF7_DBT_VERSION', '4.2. 5');14 define('CF7_DBT_DB_VERSION', '4.2. 5');13 define('CF7_DBT_VERSION', '4.2.6'); 14 define('CF7_DBT_DB_VERSION', '4.2.6'); 15 15 define('CF7_DBT_PATH', __DIR__); 16 16 define('CF7_DBT_URL', plugins_url(basename(CF7_DBT_PATH))); -
cf7-db-tool/trunk/readme.txt
r2279382 r2280329 4 4 Requires at least: 4.8 5 5 Tested up to: 5.4 6 Stable tag: 4.2. 56 Stable tag: 4.2.6 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
cf7-db-tool/trunk/src/BulkMail.php
r2278615 r2280329 93 93 94 94 $active_mailer = get_option('active_mailer'); 95 if($active_mailer){ 96 require_once 'connected_mail/mailgun.php'; 97 98 if($dbtool_group_email === 'yes' ){ 99 100 $result = sendmailbymailgun($dbtool_recipient_emails,'',$from_name,$from_email,$dbtool_subject,$dbtool_body, $attachments); 101 102 if(in_array('id',array_keys($result))){ 103 $send_mail_message = '<div class="updated">' . __( 'Your email has been successfully sent!', 'dbtool-toolkit' ) . '</div>'; 95 $mailProvider = get_option( 'select_mailer' ); 96 97 if($active_mailer ){ 98 99 if('Mailgun'===$mailProvider){ 100 require_once 'connected_mail/mailgun.php'; 101 if($dbtool_group_email === 'yes' ){ 102 103 $result = sendmailbymailgun($dbtool_recipient_emails,'',$from_name,$from_email,$dbtool_subject,$dbtool_body, $attachments); 104 105 if(in_array('id',array_keys($result))){ 106 $send_mail_message = '<div class="updated">' . __( 'Your email has been successfully sent!', 'dbtool-toolkit' ) . '</div>'; 107 } 108 else{ 109 $send_mail_message = '<div class="error">' . __( 'There was an error sending the email.', 'dbtool-toolkit' ) . '</div>'; 110 } 111 }else{ 112 foreach( $recipients as $recipient ) { 113 $result = sendmailbymailgun($recipient,'',$from_name,$from_email,$dbtool_subject,$dbtool_body, $attachments); 114 115 if(in_array('id',array_keys($result))){ 116 $send_mail_message .= '<div class="updated">' . __( 'Your email has been successfully sent to ', 'dbtool-toolkit' ) . esc_html($recipient) . '!</div>'; 117 }else{ 118 $send_mail_message .= '<div class="error">' . __( 'There was an error sending the email to ', 'dbtool-toolkit' ) . esc_html($recipient) . '</div>'; 119 } 120 } 104 121 } 122 } 123 elseif('SendGrid'===$mailProvider){ 124 require_once 'connected_mail/sendgrid.php'; 125 126 if($dbtool_group_email === 'yes' ){ 127 128 $result = sendmailBySendGrid($dbtool_recipient_emails,'',$from_name,$from_email,$dbtool_subject,$dbtool_body, $attachments); 129 $result = json_decode($result, true); 130 if(!$result){ 131 $send_mail_message = '<div class="error">' . __( 'Please Check the API URL', 'dbtool-toolkit' ) . '</div>'; 132 } 133 elseif(in_array('errors',array_keys($result))){ 134 $send_mail_message = '<div class="error">' . __( 'Bad username / password', 'dbtool-toolkit' ) . '</div>'; 135 }else{ 136 $send_mail_message = '<div class="updated">' . __( 'Your email has been successfully sent!', 'dbtool-toolkit' ) . '</div>'; 137 } 138 139 } 105 140 else{ 106 $send_mail_message = '<div class="error">' . __( 'There was an error sending the email.', 'dbtool-toolkit' ) . '</div>'; 107 } 108 }else{ 109 foreach( $recipients as $recipient ) { 110 $result = sendmailbymailgun($recipient,'',$from_name,$from_email,$dbtool_subject,$dbtool_body, $attachments); 111 112 if(in_array('id',array_keys($result))){ 113 $send_mail_message .= '<div class="updated">' . __( 'Your email has been successfully sent to ', 'dbtool-toolkit' ) . esc_html($recipient) . '!</div>'; 114 }else{ 115 $send_mail_message .= '<div class="error">' . __( 'There was an error sending the email to ', 'dbtool-toolkit' ) . esc_html($recipient) . '</div>'; 116 } 117 } 118 } 119 120 121 } 141 foreach( $recipients as $recipient ) { 142 var_dump($recipient); 143 $result = sendmailBySendGrid($dbtool_recipient_emails,'',$from_name,$from_email,$dbtool_subject,$dbtool_body, $attachments); 144 $result = json_decode($result, true); 145 if(!$result){ 146 $send_mail_message = '<div class="error">' . __( 'Please Check the API URL', 'dbtool-toolkit' ) . '</div>'; 147 break; 148 } 149 elseif(in_array('errors',array_keys($result))){ 150 $send_mail_message = '<div class="error">' . __( 'Bad username / password, Check your uasername & password', 'dbtool-toolkit' ) . '</div>'; 151 break; 152 }else{ 153 $send_mail_message .= '<div class="updated">' . __( 'Your email has been successfully sent to ', 'dbtool-toolkit' ) . esc_html($recipient) . '!</div>'; 154 } 155 } 156 } 157 } 158 } 159 122 160 else{ 123 161 if ( $dbtool_group_email === 'yes' ) { -
cf7-db-tool/trunk/src/Plugin.php
r2279382 r2280329 187 187 register_setting('mail-provider-support-group', 'mailgun-key'); 188 188 // Mailgun api url & Api Key 189 //register_setting('mail-provider-support-group', 'sendgrid-api-url');190 //register_setting('mail-provider-support-group', 'sendgrid-user');191 //register_setting('mail-provider-support-group', 'sendgrid-password');189 register_setting('mail-provider-support-group', 'sendgrid-api-url'); 190 register_setting('mail-provider-support-group', 'sendgrid-user'); 191 register_setting('mail-provider-support-group', 'sendgrid-password'); 192 192 193 193 /** … … 196 196 add_settings_section( 'section_mail_setting', 'Active & Choose Mail Provider', [$this, 'active_mail_provider__section_cb'], 'mail-support-options' ); 197 197 add_settings_section( 'mailgun_mail_setting', 'Mailgun Mail Settings ', [$this, 'mailgun_section_cb'], 'mail-support-options' ); 198 //add_settings_section( 'sendgrid_mail_setting', 'SendGrid Mail Settings ', [$this, 'sendgrid_section_cb'], 'mail-support-options' );198 add_settings_section( 'sendgrid_mail_setting', 'SendGrid Mail Settings ', [$this, 'sendgrid_section_cb'], 'mail-support-options' ); 199 199 200 200 /** … … 208 208 add_settings_field('mailgun_key','Mailgun API KEY', [$this, 'mailgun_key_field_cb'],'mail-support-options','mailgun_mail_setting'); 209 209 //For Sendgrid 210 //add_settings_field('sendgrid_url','SendGrid API URL', [$this, 'sendgrid_api_url'],'mail-support-options','sendgrid_mail_setting');211 //add_settings_field('sendgrid_username','SendGrid Username', [$this, 'sendgrid_userName'],'mail-support-options','sendgrid_mail_setting');212 //add_settings_field('sendgrid_password','SendGrid Password', [$this, 'sendgrid_userPassword'],'mail-support-options','sendgrid_mail_setting');210 add_settings_field('sendgrid_url','SendGrid API URL', [$this, 'sendgrid_api_url'],'mail-support-options','sendgrid_mail_setting'); 211 add_settings_field('sendgrid_username','SendGrid Username', [$this, 'sendgrid_userName'],'mail-support-options','sendgrid_mail_setting'); 212 add_settings_field('sendgrid_password','SendGrid Password', [$this, 'sendgrid_userPassword'],'mail-support-options','sendgrid_mail_setting'); 213 213 } 214 214 … … 221 221 $active_mailer = get_option('active_mailer'); 222 222 $checkded = ($active_mailer? 'checked' : ''); 223 echo '<label><input type="checkbox" '.$checkded.' name="active_mailer" value="1"> Active Thirdparty Mail Service </label>';223 echo '<label><input type="checkbox" '.$checkded.' name="active_mailer" class="active_mail_provider" value="1"> Active Thirdparty Mail Service </label>'; 224 224 } 225 225 … … 227 227 public function target_mail_provider(){ 228 228 $selec_provider = get_option( 'select_mailer' ); 229 229 230 $mailerList = array('Mailgun','SendGrid'); 230 231 $output=''; 231 echo '<select name="select_mailer" id="choose-mailer">';232 echo '<select name="select_mailer" required id="choose-mailer">'; 232 233 echo '<option value="">Select Provider</option>'; 233 234 foreach ($mailerList as $mailer ) { 234 $output .='<option value="'.$mailer.'" > '.$mailer.'</option>'; 235 if($selec_provider == $mailer ){ 236 $selected = 'selected'; 237 }else{ 238 $selected = ''; 239 } 240 $output .='<option value="'.$mailer.' " '.$selected.'> '.$mailer.'</option>'; 235 241 } 236 242 echo $output; 237 243 echo '</select>'; 238 239 244 } 240 245 … … 261 266 public function sendgrid_api_url(){ 262 267 $sendGridApi = get_option('sendgrid-api-url'); 263 $sendGridApi = ($sendGridApi? $sendGridApi : ' ');268 $sendGridApi = ($sendGridApi? $sendGridApi : 'https://api.sendgrid.com/'); 264 269 echo '<input type="url" class="sendgrid-input" value="'.$sendGridApi.'" name="sendgrid-api-url" placeholder="https://api.sendgrid.com/"> '; 265 270 } … … 324 329 ); 325 330 }elseif ('cf7-db-tool_page_Mail-Settings' == $hook){ 326 //wp_enqueue_script('cf7-dbt-mail-provider', CF7_DBT_URL . '/assets/js/cf7-db-mail-provider.js', ['jquery'], CF7_DBT_VERSION,true);331 wp_enqueue_script('cf7-dbt-mail-provider', CF7_DBT_URL . '/assets/js/cf7-db-mail-provider.js', ['jquery'], CF7_DBT_VERSION,true); 327 332 } 328 333
Note: See TracChangeset
for help on using the changeset viewer.