Skip to content

Commit 9a67361

Browse files
If multisite use network wide option
Related to ActiveCampaign#11
1 parent a1b8cd0 commit 9a67361

File tree

2 files changed

+48
-14
lines changed

2 files changed

+48
-14
lines changed

postmark.php

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,41 @@ function init() {
3838

3939

4040
function load_settings() {
41-
$settings = get_option( 'postmark_settings' );
41+
42+
// If on a multisite instance, get the network wide option
43+
if ( is_multisite() ){
44+
$settings = get_site_option( 'postmark_settings' );
45+
}
46+
else {
47+
$settings = get_option( 'postmark_settings' );
48+
}
49+
50+
4251

4352
if ( false === $settings ) {
44-
$settings = array(
45-
'enabled' => get_option( 'postmark_enabled', 0 ),
46-
'api_key' => get_option( 'postmark_api_key', '' ),
47-
'sender_address' => get_option( 'postmark_sender_address', '' ),
48-
'force_html' => get_option( 'postmark_force_html', 0 ),
49-
'track_opens' => get_option( 'postmark_trackopens', 0 )
50-
);
51-
52-
update_option( 'postmark_settings', json_encode( $settings ) );
53-
53+
54+
// If on a multisite instance, update the network wide option
55+
if ( is_multisite() ){
56+
$settings = array(
57+
'enabled' => get_site_option( 'postmark_enabled', 0 ),
58+
'api_key' => get_site_option( 'postmark_api_key', '' ),
59+
'sender_address' => get_site_option( 'postmark_sender_address', '' ),
60+
'force_html' => get_site_option( 'postmark_force_html', 0 ),
61+
'track_opens' => get_site_option( 'postmark_trackopens', 0 )
62+
);
63+
update_site_option( 'postmark_settings', json_encode( $settings ) );
64+
}
65+
else {
66+
$settings = array(
67+
'enabled' => get_option( 'postmark_enabled', 0 ),
68+
'api_key' => get_option( 'postmark_api_key', '' ),
69+
'sender_address' => get_option( 'postmark_sender_address', '' ),
70+
'force_html' => get_option( 'postmark_force_html', 0 ),
71+
'track_opens' => get_option( 'postmark_trackopens', 0 )
72+
);
73+
update_option( 'postmark_settings', json_encode( $settings ) );
74+
}
75+
5476
return $settings;
5577
}
5678

@@ -197,8 +219,14 @@ function save_settings() {
197219
else {
198220
$settings['track_opens'] = 0;
199221
}
200-
201-
update_option( 'postmark_settings', json_encode($settings) );
222+
223+
// If on a multisite instance, get the network wide option
224+
if ( is_multisite() ){
225+
update_site_option( 'postmark_settings', json_encode($settings) );
226+
}
227+
else {
228+
update_option( 'postmark_settings', json_encode($settings) );
229+
}
202230

203231
wp_die('Settings saved');
204232
}

wp-mail.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
66
// Compact the input, apply the filters, and extract them back out
77
extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
88

9-
$settings = json_decode( get_option( 'postmark_settings' ), true );
9+
if (is_multisite()){
10+
$settings = json_decode( get_site_option( 'postmark_settings' ), true );
11+
}
12+
else {
13+
$settings = json_decode( get_option( 'postmark_settings' ), true );
14+
}
15+
1016

1117
if ( ! is_array( $attachments ) ) {
1218
$attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );

0 commit comments

Comments
 (0)