@@ -38,19 +38,41 @@ function init() {
38
38
39
39
40
40
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
+
42
51
43
52
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
+
54
76
return $ settings ;
55
77
}
56
78
@@ -197,8 +219,14 @@ function save_settings() {
197
219
else {
198
220
$ settings ['track_opens ' ] = 0 ;
199
221
}
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
+ }
202
230
203
231
wp_die ('Settings saved ' );
204
232
}
0 commit comments