Skip to content

Commit f06f954

Browse files
Fixes for the code base
Added extra code to allow override From Name
1 parent 9640c14 commit f06f954

9 files changed

Lines changed: 348 additions & 396 deletions

File tree

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,37 @@ Before pushing any new changes, make sure you run the following command. It will
151151
find vendor/ -type d -name ".git" -exec rm -rf {} \;
152152
</code></pre>
153153

154+
## Hook for overriding the "From" details
155+
156+
You can use the wp_mail_from_name filter in WordPress to dynamically set the "From Name" based on the form submission data. Below is a workaround function that checks if the email is being sent by Ninja Forms and sets the "From Name" to the name of the form submitter.
157+
Explanation:
158+
The function hooks into the wp_mail_from_name filter.
159+
It checks if the email is being sent by Ninja Forms by inspecting the $phpmailer global object.
160+
If the email is from Ninja Forms, it retrieves the submitter's name from the email headers or content.
161+
It sets the "From Name" dynamically.
162+
163+
164+
```php
165+
add_filter('wp_mail_from_name', function ($from_name) {
166+
global $phpmailer;
167+
168+
// Check if PHPMailer is initialized
169+
if (!isset($phpmailer) || !is_object($phpmailer)) {
170+
return $from_name;
171+
}
172+
173+
// Check if the email is from Ninja Forms
174+
if (isset($phpmailer->Subject) && strpos($phpmailer->Subject, 'Ninja Forms') !== false) {
175+
// Extract the submitter's name from the email headers or body
176+
if (preg_match('/Name:\s*(.+)/i', $phpmailer->Body, $matches)) {
177+
$from_name = trim($matches[1]);
178+
}
179+
}
180+
181+
return $from_name;
182+
});
183+
```
184+
154185
## Screenshots
155186

156187
1. The initial setup wizard will guide you through the quick steps to get started

src/includes/SettingsPages/AbandonedCartSettings.php

Lines changed: 298 additions & 305 deletions
Large diffs are not rendered by default.

src/includes/SettingsPages/AllSetup.php

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,9 @@ public function mailjet_allsetup_page_html() {
3030
}
3131
?>
3232
<div class="mj-pluginPage">
33-
<div id="initialSettingsHead"><img src="
34-
<?php
35-
echo plugin_dir_url(dirname(__DIR__, 1)) . '/admin/images/LogoMJ_White_RVB.svg';
36-
?>
37-
" alt="Mailjet Logo" /></div>
33+
<div id="initialSettingsHead"><img src="<?php echo plugin_dir_url(dirname(__DIR__, 1)) . '/admin/images/LogoMJ_White_RVB.svg';?>" alt="Mailjet Logo" /></div>
3834
<div class="mainContainer allsetup">
39-
<!-- <h1>-->
40-
<?php
41-
// echo esc_html(get_admin_page_title());
42-
?>
43-
<!--</h1>-->
35+
4436
<h1 class="page_top_title">
4537
<?php
4638
echo __('You\'re all set up!', 'mailjet-for-wordpress');
@@ -53,11 +45,7 @@ public function mailjet_allsetup_page_html() {
5345
</p>
5446
<div class="allsetup_blocks">
5547
<div class="block_single">
56-
<img src="
57-
<?php
58-
echo plugin_dir_url(\dirname(__DIR__)) . '/admin/images/all_setup_screen_signup_to_newsletter.png';
59-
?>
60-
" />
48+
<img src="<?php echo plugin_dir_url(\dirname(__DIR__)) . '/admin/images/all_setup_screen_signup_to_newsletter.png';?>" />
6149
<div class="section_inner_title">
6250
<?php
6351
echo __('Add a subscription form to your website', 'mailjet-for-wordpress');
@@ -68,18 +56,10 @@ public function mailjet_allsetup_page_html() {
6856
_e('Go to the widget management page and add the Mailjet Subscription Widget to your website to start collecting email addresses.', 'mailjet-for-wordpress');
6957
?>
7058
</p>
71-
<div class="bottomBtn"><input name="nextBtnReverse" class="mj-btn btnPrimary" type="button" id="nextBtnReverse1" onclick="location.href = 'widgets.php'" value="
72-
<?php
73-
_e('Manage my widgets', 'mailjet-for-wordpress');
74-
?>
75-
"></div>
59+
<div class="bottomBtn"><input name="nextBtnReverse" class="mj-btn btnPrimary" type="button" id="nextBtnReverse1" onclick="location.href = 'widgets.php'" value="<?php _e('Manage my widgets', 'mailjet-for-wordpress'); ?>"></div>
7660
</div>
7761
<div class="block_single">
78-
<img src="
79-
<?php
80-
echo plugin_dir_url(\dirname(__DIR__)) . '/admin/images/all_setup_screen_send_campaign.png';
81-
?>
82-
" />
62+
<img src="<?php echo plugin_dir_url(\dirname(__DIR__)) . '/admin/images/all_setup_screen_send_campaign.png'; ?>" />
8363
<div class="section_inner_title">
8464
<?php
8565
echo __('Send an email campaign', 'mailjet-for-wordpress');
@@ -90,18 +70,10 @@ public function mailjet_allsetup_page_html() {
9070
_e('Ready to send a newsletter to your subscribers? Simply go to your Campaigns and click on "Create a campaign" to create and send your email.', 'mailjet-for-wordpress');
9171
?>
9272
</p>
93-
<div class="bottomBtn"><input name="nextBtnReverse" class="mj-btn btnPrimary" type="button" id="nextBtnReverse2" onclick="location.href = 'admin.php?page=mailjet_settings_campaigns_menu'" value="
94-
<?php
95-
_e('Create a campaign', 'mailjet-for-wordpress');
96-
?>
97-
"></div>
73+
<div class="bottomBtn"><input name="nextBtnReverse" class="mj-btn btnPrimary" type="button" id="nextBtnReverse2" onclick="location.href = 'admin.php?page=mailjet_settings_campaigns_menu'" value="<?php _e('Create a campaign', 'mailjet-for-wordpress');?>"></div>
9874
</div>
9975
<div class="block_single">
100-
<img src="
101-
<?php
102-
echo plugin_dir_url(\dirname(__DIR__)) . '/admin/images/all_setup_screen_configure.png';
103-
?>
104-
" />
76+
<img src="<?php echo plugin_dir_url(\dirname(__DIR__)) . '/admin/images/all_setup_screen_configure.png';?>" />
10577
<div class="section_inner_title">
10678
<?php
10779
echo __('Configure WordPress email sending', 'mailjet-for-wordpress');
@@ -112,11 +84,7 @@ public function mailjet_allsetup_page_html() {
11284
_e('Enable and configure sending of all your WordPress emails (transactional emails, etc...) through Mailjet.', 'mailjet-for-wordpress');
11385
?>
11486
</p>
115-
<div class="bottomBtn"><input name="nextBtnReverse" class="mj-btn btnPrimary" type="button" id="nextBtnReverse3" onclick="location.href = 'admin.php?page=mailjet_sending_settings_page'" value="
116-
<?php
117-
_e('Configure', 'mailjet-for-wordpress');
118-
?>
119-
"></div>
87+
<div class="bottomBtn"><input name="nextBtnReverse" class="mj-btn btnPrimary" type="button" id="nextBtnReverse3" onclick="location.href = 'admin.php?page=mailjet_sending_settings_page'" value="<?php _e('Configure', 'mailjet-for-wordpress'); ?>"></div>
12088
</div>
12189
</div>
12290

src/includes/SettingsPages/ConnectAccountSettings.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ public function mailjet_connect_account_cb( $args ) {
4747
// output the field
4848
?>
4949
<fieldset class="settingsConnectFldset">
50-
<!--<input name="settings_step" type="hidden" id="settings_step" value="initial_step">-->
51-
5250
<label class="mj-label" for="mailjet_apikey">
5351
<?php
5452
_e('<b>Api Key</b>', 'mailjet-for-wordpress');
@@ -116,10 +114,7 @@ public function mailjet_connect_account_page_html() {
116114
?>
117115

118116
<div class="mj-pluginPage">
119-
<div id="initialSettingsHead"><img src="
120-
<?php
121-
echo plugin_dir_url(dirname(__DIR__, 1)) . '/admin/images/LogoMJ_White_RVB.svg';
122-
?>
117+
<div id="initialSettingsHead"><img src="<?php echo plugin_dir_url(dirname(__DIR__, 1)) . '/admin/images/LogoMJ_White_RVB.svg';?>
123118
" alt="Mailjet Logo" /></div>
124119
<div class="mainContainer">
125120

@@ -146,11 +141,6 @@ public function mailjet_connect_account_page_html() {
146141

147142
<div class="right">
148143
<div class="centered">
149-
<!-- <h1>-->
150-
<?php
151-
// echo esc_html(get_admin_page_title());
152-
?>
153-
<!--</h1>-->
154144
<h2 class="section_inner_title">
155145
<?php
156146
echo __('Connect your Mailjet account', 'mailjet-for-wordpress');

src/includes/SettingsPages/ContactForm7Settings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public function sendConfirmationEmail( $contactForm ): bool {
3838
if ( ! empty($invalidFields)) {
3939
return false;
4040
}
41-
$mailjetCheckbox = $formdata[ self::MAILJET_CHECKBOX ];
42-
if ($mailjetCheckbox[0] != '') {
41+
$mailjetCheckbox = $formdata[ self::MAILJET_CHECKBOX ] ?? [];
42+
if (isset($mailjetCheckbox[0]) && !empty($mailjetCheckbox[0])) {
4343
$cf7Email = trim(stripslashes(Mailjet::getOption('cf7_email')), '[]');
4444

4545
if ( ! isset($formdata[ $cf7Email ])) {

src/includes/SettingsPages/Dashboard.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,7 @@ public function mailjet_dashboard_page_html() {
3535

3636
<div class="mj-pluginPage">
3737
<div id="initialSettingsHead"><img
38-
src="
39-
<?php
40-
echo plugin_dir_url(dirname(__DIR__, 1)) . '/admin/images/LogoMJ_White_RVB.svg';
41-
?>
42-
"
43-
alt="Mailjet Logo"/></div>
38+
src="<?php echo plugin_dir_url(dirname(__DIR__, 1)) . '/admin/images/LogoMJ_White_RVB.svg';?>" alt="Mailjet Logo"/></div>
4439
<div class="mainContainer dashboard">
4540
<div id="mj-top_bar">
4641
<section
@@ -111,11 +106,7 @@ class="dashicons dashicons-admin-generic">
111106
_e('Order notification emails', 'mailjet-for-wordpress');
112107
?>
113108
</h3>
114-
<img alt="asd" class="mj-woo-logo-small" src="
115-
<?php
116-
echo esc_attr($iconDir);
117-
?>
118-
"/>
109+
<img alt="asd" class="mj-woo-logo-small" src="<?php echo esc_attr($iconDir); ?>"/>
119110
</div>
120111
<p class="blockText">
121112
<?php
@@ -182,11 +173,7 @@ class="dashicons dashicons-admin-generic">
182173
_e('Abandoned cart email', 'mailjet-for-wordpress');
183174
?>
184175
</h3>
185-
<img alt="asd" class="mj-woo-logo-small" src="
186-
<?php
187-
echo esc_attr($iconDir);
188-
?>
189-
"/>
176+
<img alt="asd" class="mj-woo-logo-small" src="<?php echo esc_attr($iconDir);?> "/>
190177
</div>
191178
<p class="blockText">
192179
<?php

src/includes/SettingsPages/EnableSendingSettings.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ public function mailjet_enable_sending_cb( $args ) {
128128
<?php
129129
if ( ! empty($mailjet_from_email_extra)) {
130130
?>
131-
<input name="mailjet_from_email_extra_hidden" type="hidden" id="mailjet_from_email_extra_hidden" value="
132-
<?php
133-
_e($mailjet_from_email_extra);
134-
?>
135-
">
131+
<input name="mailjet_from_email_extra_hidden" type="hidden" id="mailjet_from_email_extra_hidden" value="<?php _e($mailjet_from_email_extra); ?> ">
136132
<?php
137133
}
138134
?>
@@ -290,11 +286,7 @@ public function mailjet_sending_settings_page_html() {
290286
?>
291287

292288
<div class="mj-pluginPage">
293-
<div id="initialSettingsHead"><img src="
294-
<?php
295-
echo plugin_dir_url(\dirname(__DIR__)) . '/admin/images/LogoMJ_White_RVB.svg';
296-
?>
297-
" alt="Mailjet Logo" /></div>
289+
<div id="initialSettingsHead"><img src=" <?php echo plugin_dir_url(\dirname(__DIR__)) . '/admin/images/LogoMJ_White_RVB.svg'; ?> " alt="Mailjet Logo" /></div>
298290
<div class="mainContainer">
299291

300292
<div class="backToDashboard">
@@ -320,11 +312,6 @@ public function mailjet_sending_settings_page_html() {
320312

321313
<div class="right">
322314
<div class="centered" style="width:650px;">
323-
<!-- <h1>-->
324-
<?php
325-
// echo esc_html(get_admin_page_title());
326-
?>
327-
<!--</h1>-->
328315
<h2 class="section_inner_title">
329316
<?php
330317
_e('Sending settings', 'mailjet-for-wordpress');

src/templates/admin/WooCommerceSettingsTemplates/rowTemplate.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@
5050
<?php
5151
}
5252
?>
53-
<button class="mj-btnSecondary mj-inrow" onclick="location.href='
54-
<?php
55-
echo esc_attr($templateLink);
56-
?>
57-
'" type="button">
53+
<button class="mj-btnSecondary mj-inrow" onclick="location.href='<?php echo esc_attr($templateLink); ?>'" type="button">
5854
<?php
5955
_e('Edit', 'mailjet-for-wordpress');
6056
?>

wp-mailjet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Plugin Name: Mailjet for WordPress
1515
* Plugin URI: https://www.mailjet.com/partners/wordpress/
1616
* Description: The Best WordPress Plugin For Email Newsletters.
17-
* Version: 6.1.5
17+
* Version: 6.1.6
1818
* Tested up to: 6.8.1
1919
* Author: Mailjet SAS
2020
* Author URI: http://mailjet.com
@@ -56,7 +56,7 @@
5656
/**
5757
* Mailjet plugin version.
5858
*/
59-
define('MAILJET_VERSION', '6.1.5');
59+
define('MAILJET_VERSION', '6.1.6');
6060

6161
/**
6262
* Mailjet Plugid dir.

0 commit comments

Comments
 (0)