PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.3 6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 All 156 releases
← All changes | class/class-mainwp-notification-settings.php +767 -635 5.0.3.1 → 6.2.2 View file →
@@ -6,714 +6,846 @@
6 6 */
7 7
8 8 namespace MainWP\Dashboard;
9 9
10 +// Exit if accessed directly.
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
14 +
10 15 /**
11 16 * Class MainWP_Notification_Settings
12 17 *
13 18 * @package MainWP\Dashboard
14 19 */
15 -class MainWP_Notification_Settings {
20 +class MainWP_Notification_Settings { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
16 21
17 - /**
18 - * Private static variable to hold the single instance of the class.
19 - *
20 - * @static
21 - *
22 - * @var mixed Default null.
23 - */
24 - private static $instance = null;
25 22
23 + /**
24 + * Private static variable to hold the single instance of the class.
25 + *
26 + * @static
27 + *
28 + * @var mixed Default null.
29 + */
30 + private static $instance = null;
26 31
27 - /**
28 - * Get class name.
29 - *
30 - * @return string Class name.
31 - */
32 - public static function get_class_name() {
33 - return __CLASS__;
34 - }
32 + /**
33 + * Private static variable to hold the single instance.
34 + *
35 + * @static
36 + *
37 + * @var mixed Default null.
38 + */
39 + private static $boilerplate_tokens_loaded = null;
35 40
36 - /**
37 - * Create a new self instance.
38 - *
39 - * @return mixed self::$instance
40 - */
41 - public static function instance() {
42 - if ( null === self::$instance ) {
43 - self::$instance = new self();
44 - }
45 - return self::$instance;
46 - }
47 41
48 - /**
49 - * MainWP_Notification_Settings constructor.
50 - *
51 - * Run each time the class is called.
52 - */
53 - public function __construct() {
54 - }
42 + /**
43 + * Private static variable to hold the single instance.
44 + *
45 + * @static
46 + *
47 + * @var mixed Default null.
48 + */
49 + private static $report_tokens_loaded = null;
55 50
56 - /**
57 - * Manage general email settings.
58 - *
59 - * @return bool True if saved successfully, false if not.
60 - *
61 - * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
62 - */
63 - public static function emails_general_settings_handle() {
64 - if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'SettingsEmail' ) ) {
65 - $emails_settings = get_option( 'mainwp_settings_notification_emails' );
66 - if ( ! is_array( $emails_settings ) ) {
67 - $emails_settings = array();
68 - }
51 + /**
52 + * Private static variable to hold the single instance.
53 + *
54 + * @static
55 + *
56 + * @var mixed Default null.
57 + */
58 + private static $client_report_tokens_loaded = null;
69 59
70 - $type = isset( $_POST['mainwp_setting_emails_type'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_setting_emails_type'] ) ) : '';
71 - $update_settings = isset( $_POST['mainwp_settingEmails'][ $type ] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['mainwp_settingEmails'][ $type ] ) ) : '';
72 - $update_settings['disable'] = ( isset( $_POST['mainwp_settingEmails'][ $type ] ) && isset( $_POST['mainwp_settingEmails'][ $type ]['disable'] ) ) ? 0 : 1; // to set 'disable' values.
73 - $emails_settings[ $type ] = $update_settings;
74 60
75 - /**
76 - * Action: mainwp_before_save_email_settings
77 - *
78 - * Fires before save email settings.
79 - *
80 - * @since 4.1
81 - */
82 - do_action( 'mainwp_before_save_email_settings', $type, $update_settings );
61 + /**
62 + * Get class name.
63 + *
64 + * @return string Class name.
65 + */
66 + public static function get_class_name() {
67 + return __CLASS__;
68 + }
83 69
84 - MainWP_Utility::update_option( 'mainwp_settings_notification_emails', $emails_settings );
70 + /**
71 + * Create a new self instance.
72 + *
73 + * @return mixed static::$instance
74 + */
75 + public static function instance() {
76 + if ( null === static::$instance ) {
77 + static::$instance = new self();
78 + }
79 + return static::$instance;
80 + }
85 81
86 - /**
87 - * Action: mainwp_after_save_email_settings
88 - *
89 - * Fires after save email settings.
90 - *
91 - * @since 4.1
92 - */
93 - do_action( 'mainwp_after_save_email_settings', $emails_settings );
82 + /**
83 + * MainWP_Notification_Settings constructor.
84 + *
85 + * Run each time the class is called.
86 + */
87 + public function __construct() {
88 + }
94 89
95 - return true;
96 - }
97 - return false;
98 - }
90 + /**
91 + * Manage general email settings.
92 + *
93 + * @return bool True if saved successfully, false if not.
94 + *
95 + * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
96 + */
97 + public static function emails_general_settings_handle() {
98 + if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'SettingsEmail' ) ) {
99 + $emails_settings = get_option( 'mainwp_settings_notification_emails' );
100 + if ( ! is_array( $emails_settings ) ) {
101 + $emails_settings = array();
102 + }
99 103
100 - /**
101 - * Render all email settings options.
102 - *
103 - * Credits.
104 - *
105 - * Plugin-Name: WooCommerce.
106 - * Plugin URI: https://woocommerce.com/.
107 - * Author: Automattic.
108 - * Author URI: https://woocommerce.com.
109 - * License: GPLv3 or later.
110 - *
111 - * @param bool $updated True if page loaded after update, false if not.
112 - */
113 - public function render_all_settings( $updated ) {
104 + $type = isset( $_POST['mainwp_setting_emails_type'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_setting_emails_type'] ) ) : '';
105 + $update_settings = isset( $_POST['mainwp_settingEmails'][ $type ] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['mainwp_settingEmails'][ $type ] ) ) : '';
106 + $update_settings['disable'] = ( isset( $_POST['mainwp_settingEmails'][ $type ] ) && isset( $_POST['mainwp_settingEmails'][ $type ]['disable'] ) ) ? 0 : 1; // to set 'disable' values.
107 + $emails_settings[ $type ] = $update_settings;
114 108
115 - if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) {
116 - mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
117 - return;
118 - }
109 + /**
110 + * Action: mainwp_before_save_email_settings
111 + *
112 + * Fires before save email settings.
113 + *
114 + * @since 4.1
115 + */
116 + do_action( 'mainwp_before_save_email_settings', $type, $update_settings );
119 117
120 - $email_description = '';
121 - $notification_emails = self::get_notification_types();
122 - $emails_settings = get_option( 'mainwp_settings_notification_emails' );
123 - if ( ! is_array( $emails_settings ) ) {
124 - $emails_settings = array();
125 - }
118 + MainWP_Utility::update_option( 'mainwp_settings_notification_emails', $emails_settings );
126 119
127 - ?>
128 - <div id="mainwp-all-emails-settings" class="ui segment">
129 - <?php if ( $updated ) : ?>
130 - <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
131 - <?php endif; ?>
132 - <div class="ui info message">
133 - <?php printf( esc_html__( 'Email notifications sent from MainWP Dashboard are listed below. Click on an email to configure it. For additional help, please see %1$sthis help document%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/email-settings/">', '</a> <i class="external alternate icon"></i>' ); ?>
134 - </div>
135 - <table class="ui unstackable table" id="mainwp-emails-settings-table">
136 - <thead>
137 - <tr>
138 - <th class="collapsing"><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
139 - <th data-priority="1"><?php esc_html_e( 'Email', 'mainwp' ); ?></th>
140 - <th><?php esc_html_e( 'Description', 'mainwp' ); ?></th>
141 - <th ><?php esc_html_e( 'Recipient(s)', 'mainwp' ); ?></th>
142 - <th class="no-sort collapsing" data-priority="2" style="text-align:right">&nbsp;</th>
143 - </tr>
144 - </thead>
145 - <tbody>
146 - <?php foreach ( $notification_emails as $type => $name ) : ?>
147 - <?php
148 - $options = isset( $emails_settings[ $type ] ) ? $emails_settings[ $type ] : array();
149 - $default = self::get_default_emails_fields( $type, '', true );
150 - $options = array_merge( $default, $options );
120 + /**
121 + * Action: mainwp_after_save_email_settings
122 + *
123 + * Fires after save email settings.
124 + *
125 + * @since 4.1
126 + */
127 + do_action( 'mainwp_after_save_email_settings', $emails_settings );
151 128
152 - $email_description = self::get_settings_desc( $type );
153 - ?>
154 - <tr>
155 - <td><?php echo ( ! $options['disable'] ) ? '<span data-tooltip="Enabled." data-position="right center" data-inverted=""><i class="circular green check inverted icon"></i></span>' : '<span data-tooltip="Disabled." data-position="right center" data-inverted=""><i class="circular x icon inverted disabled"></i></span>'; ?></td>
156 - <td><a href="admin.php?page=SettingsEmail&edit-email=<?php echo esc_html( rawurlencode( $type ) ); ?>" data-tooltip="<?php esc_attr_e( 'Click to configure the email.', 'mainwp' ); ?>" data-position="right center" data-inverted=""><?php echo esc_html( $name ); ?></a></td>
157 - <td><?php echo esc_html( $email_description ); ?></td>
158 - <td><?php echo esc_html( $options['recipients'] ); ?></td>
159 - <td style="text-align:right"><a href="admin.php?page=SettingsEmail&edit-email=<?php echo esc_html( rawurlencode( $type ) ); ?>" data-tooltip="<?php esc_attr_e( 'Click to configure the email.', 'mainwp' ); ?>" data-position="left center" data-inverted="" class="ui green mini button"><?php esc_html_e( 'Manage', 'mainwp' ); ?></a></td>
160 - </tr>
161 - <?php endforeach; ?>
162 - </tbody>
163 - <tfoot>
164 - <tr>
165 - <th class="collapsing"><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
166 - <th><?php esc_html_e( 'Email', 'mainwp' ); ?></th>
167 - <th><?php esc_html_e( 'Description', 'mainwp' ); ?></th>
168 - <th><?php esc_html_e( 'Recipient(s)', 'mainwp' ); ?></th>
169 - <th>&nbsp;</th>
170 - </tr>
171 - </tfoot>
172 - </table>
173 - <?php
174 - /**
175 - * Action: mainwp_settings_email_settings
176 - *
177 - * Fires after the default email settings.
178 - *
179 - * @since 4.1
180 - */
181 - do_action( 'mainwp_settings_email_settings' );
182 - ?>
183 - <script type="text/javascript">
184 - var responsive = true;
185 - if( jQuery( window ).width() > 1140 ) {
186 - responsive = false;
187 - }
188 - jQuery( document ).ready( function() {
189 - jQuery( '#mainwp-emails-settings-table' ).DataTable( {
190 - "stateSave": true,
191 - "paging": false,
192 - "ordering": true,
193 - "columnDefs": [ { "orderable": false, "targets": [ 4 ] } ],
194 - "order": [ [ 2, "asc" ] ],
195 - "responsive": responsive,
196 - } );
197 - } );
198 - </script>
199 - </div>
200 - <?php
201 - }
129 + return true;
130 + }
131 + return false;
132 + }
202 133
203 - /**
204 - * Render email settings page.
205 - *
206 - * Credits.
207 - *
208 - * Plugin-Name: WooCommerce.
209 - * Plugin URI: https://woocommerce.com/.
210 - * Author: Automattic.
211 - * Author URI: https://woocommerce.com.
212 - * License: GPLv3 or later.
213 - *
214 - * @param string $type Email notification type.
215 - * @param bool $updated_templ True if page loaded after update, false if not.
216 - *
217 - * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::render_edit_template()
218 - * @uses \MainWP\Dashboard\MainWP_Notification_Template::get_template_name_by_notification_type()
219 - * @uses \MainWP\Dashboard\MainWP_Notification_Template::is_overrided_template()
220 - */
221 - public function render_edit_settings( $type, $updated_templ ) {
134 + /**
135 + * Render all email settings options.
136 + *
137 + * Credits.
138 + *
139 + * Plugin-Name: WooCommerce.
140 + * Plugin URI: https://woocommerce.com/.
141 + * Author: Automattic.
142 + * Author URI: https://woocommerce.com.
143 + * License: GPLv3 or later.
144 + *
145 + * @param bool $updated True if page loaded after update, false if not.
146 + */
147 + public function render_all_settings( $updated ) {
222 148
223 - if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) {
224 - mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
225 - return;
226 - }
149 + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) {
150 + \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
151 + return;
152 + }
227 153
228 - $emails_settings = get_option( 'mainwp_settings_notification_emails' );
229 - if ( ! is_array( $emails_settings ) ) {
230 - $emails_settings = array();
231 - }
154 + $email_description = '';
155 + $notification_emails = static::get_notification_types();
156 + $emails_settings = get_option( 'mainwp_settings_notification_emails' );
157 + if ( ! is_array( $emails_settings ) ) {
158 + $emails_settings = array();
159 + }
232 160
233 - $options = isset( $emails_settings[ $type ] ) ? $emails_settings[ $type ] : array();
161 + ?>
162 + <div id="mainwp-all-emails-settings" class="ui padded segment">
163 + <?php if ( $updated ) : ?>
164 + <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
165 + <?php endif; ?>
166 + <div class="ui info message">
167 + <?php
168 + /* translators: 1: Opening anchor tag, 2: Closing anchor tag with external link icon */
169 + printf( esc_html__( 'Email notifications sent from MainWP Dashboard are listed below. Click on an email to configure it. For additional help, please see %1$sthis help document%2$s.', 'mainwp' ), '<a href="https://docs.mainwp.com/sites/management/mainwp-dashboard-settings#manage-email-settings">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe.
170 + ?>
171 + </div>
172 + <table class="ui unstackable table" id="mainwp-emails-settings-table">
173 + <thead>
174 + <tr>
175 + <th scope="col" class="collapsing"><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
176 + <th scope="col" data-priority="1"><?php esc_html_e( 'Email', 'mainwp' ); ?></th>
177 + <th scope="col"><?php esc_html_e( 'Description', 'mainwp' ); ?></th>
178 + <th scope="col"><?php esc_html_e( 'Recipient(s)', 'mainwp' ); ?></th>
179 + <th scope="col" class="no-sort collapsing" data-priority="2" style="text-align:right">&nbsp;</th>
180 + </tr>
181 + </thead>
182 + <tbody>
183 + <?php foreach ( $notification_emails as $type => $name ) : ?>
184 + <?php
185 + $options = isset( $emails_settings[ $type ] ) ? $emails_settings[ $type ] : array();
186 + $default = static::get_default_emails_fields( $type, '', true );
187 + $options = array_merge( $default, $options );
234 188
235 - $default = self::get_default_emails_fields( $type, '', true );
236 - $options = array_merge( $default, $options );
189 + $email_description = static::get_settings_desc( $type );
190 + ?>
191 + <tr>
192 + <td><?php echo ( ! $options['disable'] ) ? '<span data-tooltip="Enabled." data-position="right center" data-inverted=""><i class="circular green check inverted icon"></i></span>' : '<span data-tooltip="Disabled." data-position="right center" data-inverted=""><i class="circular x icon inverted disabled"></i></span>'; ?></td>
193 + <td><a href="admin.php?page=SettingsEmail&edit-email=<?php echo esc_html( rawurlencode( $type ) ); ?>" data-tooltip="<?php esc_attr_e( 'Click to configure the email.', 'mainwp' ); ?>" data-position="right center" data-inverted=""><?php echo esc_html( $name ); ?></a></td>
194 + <td><?php echo esc_html( $email_description ); ?></td>
195 + <td><?php echo esc_html( $options['recipients'] ); ?></td>
196 + <td style="text-align:right"><a href="admin.php?page=SettingsEmail&edit-email=<?php echo esc_html( rawurlencode( $type ) ); ?>" data-tooltip="<?php esc_attr_e( 'Click to configure the email.', 'mainwp' ); ?>" data-position="left center" data-inverted="" class="ui green mini button"><?php esc_html_e( 'Manage', 'mainwp' ); ?></a></td>
197 + </tr>
198 + <?php endforeach; ?>
199 + </tbody>
200 + <tfoot>
201 + <tr>
202 + <th scope="col" class="collapsing"><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
203 + <th scope="col"><?php esc_html_e( 'Email', 'mainwp' ); ?></th>
204 + <th scope="col"><?php esc_html_e( 'Description', 'mainwp' ); ?></th>
205 + <th scope="col"><?php esc_html_e( 'Recipient(s)', 'mainwp' ); ?></th>
206 + <th scope="col">&nbsp;</th>
207 + </tr>
208 + </tfoot>
209 + </table>
210 + <?php
211 + /**
212 + * Action: mainwp_settings_email_settings
213 + *
214 + * Fires after the default email settings.
215 + *
216 + * @since 4.1
217 + */
218 + do_action( 'mainwp_settings_email_settings' );
219 + ?>
220 + <script type="text/javascript">
221 + var responsive = true;
222 + if( jQuery( window ).width() > 1140 ) {
223 + responsive = false;
224 + }
225 + jQuery( document ).ready( function() {
226 + jQuery( '#mainwp-emails-settings-table' ).DataTable( {
227 + "stateSave": true,
228 + "paging": false,
229 + "ordering": true,
230 + "columnDefs": [ { "orderable": false, "targets": [ 4 ] } ],
231 + "order": [ [ 2, "asc" ] ],
232 + "responsive": responsive,
233 + } );
234 + } );
235 + </script>
236 + </div>
237 + <?php
238 + }
237 239
238 - $title = self::get_notification_types( $type );
240 + /**
241 + * Render email settings page.
242 + *
243 + * Credits.
244 + *
245 + * Plugin-Name: WooCommerce.
246 + * Plugin URI: https://woocommerce.com/.
247 + * Author: Automattic.
248 + * Author URI: https://woocommerce.com.
249 + * License: GPLv3 or later.
250 + *
251 + * @param string $type Email notification type.
252 + * @param bool $updated_templ True if page loaded after update, false if not.
253 + *
254 + * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::render_edit_template()
255 + * @uses \MainWP\Dashboard\MainWP_Notification_Template::get_template_name_by_notification_type()
256 + * @uses \MainWP\Dashboard\MainWP_Notification_Template::is_overrided_template()
257 + */
258 + public function render_edit_settings( $type, $updated_templ ) {
239 259
240 - $email_description = self::get_settings_desc( $type );
260 + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) {
261 + \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
262 + return;
263 + }
241 264
242 - ?>
243 - <div id="mainwp-emails-settings" class="ui segment">
244 - <?php self::render_update_template_message( $updated_templ ); ?>
245 - <div class="ui form">
246 - <form method="POST" action="admin.php?page=SettingsEmail">
247 - <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'SettingsEmail' ) ); ?>" />
248 - <input type="hidden" name="mainwp_setting_emails_type" value="<?php echo esc_html( $type ); ?>" />
249 - <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-email-tokens-info-message' ) ) : ?>
250 - <div class="ui info message">
251 - <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-updates-message"></i>
252 - <?php printf( esc_html__( '%1$sBoilerplate%2$s and %3$sReports%4$s extensions tokens are supported in the email settings and templates if Extensions are in use.', 'mainwp' ), '<a href="https://mainwp.com/extension/boilerplate/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://mainwp.com/extension/pro-reports/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?>
253 - </div>
254 - <?php endif; ?>
255 - <h3 class="ui header">
256 - <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-email-' . esc_attr( $type ), 'email-settings' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
257 - <?php echo esc_html( $title ); ?></h3>
258 - <div class="sub header"><?php echo esc_html( $email_description ); ?></h3></div>
259 - <div class="ui divider"></div>
260 - <div class="ui grid field settings-field-indicator-email-<?php echo esc_attr( $type ); ?>">
261 - <label class="six wide column middle aligned">
262 - <?php
263 - MainWP_Settings_Indicator::render_not_default_email_settings_indicator( $type, 'disable', (int) $options['disable'] );
264 - esc_html_e( 'Enable', 'mainwp' );
265 - ?>
266 - </label>
267 - <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable this email notification.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
268 - <input type="checkbox" name="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][disable]" id="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][disable]" <?php echo ( 0 === (int) $options['disable'] ) ? 'checked="true"' : ''; ?>/>
269 - </div>
270 - </div>
271 - <div class="ui grid field settings-field-indicator-email-<?php echo esc_attr( $type ); ?>">
272 - <label class="six wide column middle aligned">
273 - <?php
274 - MainWP_Settings_Indicator::render_not_default_email_settings_indicator( $type, 'recipients', $options['recipients'] );
275 - esc_html_e( 'Recipient(s)', 'mainwp' );
276 - ?>
277 - </label>
278 - <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'You can add multiple emails by separating them with comma.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
279 - <input type="text" name="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][recipients]" id="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][recipients]" value="<?php echo esc_html( $options['recipients'] ); ?>"/>
280 - </div>
281 - </div>
282 - <div class="ui grid field settings-field-indicator-email-<?php echo esc_attr( $type ); ?>">
283 - <label class="six wide column middle aligned">
284 - <?php
285 - MainWP_Settings_Indicator::render_not_default_email_settings_indicator( $type, 'subject', $options['subject'] );
286 - esc_html_e( 'Subject', 'mainwp' );
287 - ?>
288 - </label>
289 - <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enter the email subject.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
290 - <input type="text" name="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][subject]" id="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][subject]" value="<?php echo esc_html( $options['subject'] ); ?>"/>
291 - </div>
292 - </div>
293 - <div class="ui grid field settings-field-indicator-email-<?php echo esc_attr( $type ); ?>">
294 - <label class="six wide column middle aligned">
295 - <?php
296 - MainWP_Settings_Indicator::render_not_default_email_settings_indicator( $type, 'heading', $options['heading'] );
297 - esc_html_e( 'Email heading', 'mainwp' );
298 - ?>
299 - </label>
300 - <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enter the email heading.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
301 - <input type="text" name="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][heading]" id="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][heading]" value="<?php echo esc_html( $options['heading'] ); ?>"/>
302 - </div>
303 - </div>
304 - <div class="ui grid field settings-field-indicator-email-<?php echo esc_attr( $type ); ?>" >
305 - <?php
306 - $templ = MainWP_Notification_Template::get_template_name_by_notification_type( $type );
307 - $overrided = MainWP_Notification_Template::instance()->is_overrided_template( $type );
308 - ?>
309 - <label class="six wide column middle aligned">
310 - <?php
311 - MainWP_Settings_Indicator::render_not_default_email_settings_indicator( $type, 'overrided', (int) $overrided );
312 - esc_html_e( 'HTML template', 'mainwp' );
313 - ?>
314 - </label>
315 - <div class="ui ten wide column" data-tooltip="<?php esc_attr_e( 'Manage the email HTML template.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
316 - <?php
317 - /**
318 - *
319 - * Use mainwp_notification_template_copy_message instead.
320 - *
321 - * @deprecated Since v4.3.
322 - */
323 - $copy_message = apply_filters( 'minwp_notification_template_copy_message', '', $templ, $type, $overrided );
324 - /**
325 - *
326 - * Filter mainwp_notification_template_copy_message.
327 - *
328 - * @since v4.3
329 - */
330 - $copy_message = apply_filters( 'mainwp_notification_template_copy_message', $copy_message, $templ, $type, $overrided );
331 - if ( empty( $copy_message ) ) {
332 - $copy_message = $overrided ? esc_html__( 'This template has been overridden and can be found in:', 'mainwp' ) . ' <code>wp-content/uploads/mainwp/templates/' . esc_html( $templ ) . '</code>' : esc_html__( 'To override and edit this email template copy:', 'mainwp' ) . ' <code>mainwp/templates/' . esc_html( $templ ) . '</code> ' . esc_html__( 'to the folder:', 'mainwp' ) . ' <code>wp-content/uploads/mainwp/templates/' . esc_html( $templ ) . '</code>';
333 - }
334 - echo $copy_message; // phpcs:ignore WordPress.Security.EscapeOutput
335 - ?>
336 - </div>
337 - </div>
338 - <div class="ui grid field settings-field-indicator-email-<?php echo esc_attr( $type ); ?>" >
339 - <label class="six wide column middle aligned"></label>
340 - <div class="ui ten wide column" data-tooltip="<?php esc_attr_e( 'Manage the email HTML template.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
341 - <?php if ( $overrided ) : ?>
342 - <a href="<?php echo esc_url( wp_nonce_url( 'admin.php?page=SettingsEmail&edit-email=' . $type, 'delete-email-template' ) ); ?>" onclick="mainwp_confirm('<?php echo esc_js( 'Are you sure you want to delete this template file?', 'mainwp' ); ?>', function(){ window.location = jQuery('a#email-delete-template').attr('href');}); return false;" id="email-delete-template" class="ui button"><?php esc_html_e( 'Return to Default Template', 'mainwp' ); ?></a>
343 - <?php else : ?>
344 - <a href="<?php echo esc_url( wp_nonce_url( 'admin.php?page=SettingsEmail&edit-email=' . $type, 'copy-email-template' ) ); ?>" class="ui button"><?php esc_html_e( 'Copy file to uploads', 'mainwp' ); ?></a>
345 - <?php endif; ?>
346 - <?php if ( $overrided ) : ?>
347 - <a href="javascript:void(0)" class="ui button" onclick="mainwp_view_template('<?php echo esc_js( $type ); ?>', true ); return false;"><?php esc_html_e( 'Edit Template', 'mainwp' ); ?></a>
348 - <?php else : ?>
349 - <a href="javascript:void(0)" class="ui button" onclick="mainwp_view_template('<?php echo esc_js( $type ); ?>', true ); return false;"><?php esc_html_e( 'View Template', 'mainwp' ); ?></a>
350 - <?php endif; ?>
351 - </div>
352 - </div>
353 - <div class="ui divider"></div>
354 - <a href="admin.php?page=SettingsEmail" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
355 - <input type="submit" name="submit" id="submit" class="ui green big button right floated" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
356 - <div style="clear:both"></div>
357 - </form>
358 - </div>
359 - </div>
360 - <?php MainWP_Manage_Sites_View::render_edit_template( $type ); ?>
361 - <?php
362 - }
265 + $emails_settings = get_option( 'mainwp_settings_notification_emails' );
266 + if ( ! is_array( $emails_settings ) ) {
267 + $emails_settings = array();
268 + }
363 269
270 + $options = isset( $emails_settings[ $type ] ) ? $emails_settings[ $type ] : array();
364 271
365 - /**
366 - * Get email settings description.
367 - *
368 - * @param string $type Email notification type.
369 - *
370 - * @return string $email_description Email settings Description.
371 - */
372 - public static function get_settings_desc( $type ) {
373 - $email_description = '';
374 - if ( 'daily_digest' === $type ) {
375 - $email_description = esc_html__( 'Daily notification about available updates and disconnected sites.', 'mainwp' );
376 - } elseif ( 'uptime' === $type ) {
377 - $email_description = esc_html__( 'Alert if any of your websites is down.', 'mainwp' );
378 - } elseif ( 'site_health' === $type ) {
379 - $email_description = esc_html__( 'Alert if any of your websites site health goes under the threshold.', 'mainwp' );
380 - } elseif ( 'http_check' === $type ) {
381 - $email_description = esc_html__( 'Alert if any of your websites return unexpected HTTP status after running updates.', 'mainwp' );
382 - } elseif ( 'deactivated_license_alert' === $type ) {
383 - $email_description = esc_html__( 'Receive a notification when an extension\'s license is deactivated.', 'mainwp' );
384 - }
272 + $default = static::get_default_emails_fields( $type, '', true );
273 + $options = array_merge( $default, $options );
385 274
386 - $addition_desc = apply_filters( 'mainwp_notification_type_desc', '', $type );
387 - if ( ! empty( $addition_desc ) ) {
388 - $email_description = $addition_desc;
389 - }
275 + $title = static::get_notification_types( $type );
390 276
391 - return $email_description;
392 - }
277 + $email_description = static::get_settings_desc( $type );
393 278
394 - /**
395 - * Render the notification after the update process.
396 - *
397 - * @param int $updated Update code (copied, saved or deleted).
398 - */
399 - public static function render_update_template_message( $updated ) {
400 - ?>
401 - <?php if ( 1 === (int) $updated ) : ?>
402 - <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Custom email template deleted successfully.', 'mainwp' ); ?></div>
403 - <?php endif; ?>
404 - <?php if ( 2 === (int) $updated ) : ?>
405 - <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Email template copied successfully.', 'mainwp' ); ?></div>
406 - <?php endif; ?>
407 - <?php if ( 3 === (int) $updated ) : ?>
408 - <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Email template updated successfully.', 'mainwp' ); ?></div>
409 - <?php endif; ?>
410 - <?php
411 - }
279 + ?>
280 + <div id="mainwp-emails-settings" class="ui segment">
281 + <?php static::render_update_template_message( $updated_templ ); ?>
282 + <div class="ui form">
283 + <form method="POST" action="admin.php?page=SettingsEmail">
284 + <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'SettingsEmail' ) ); ?>" />
285 + <input type="hidden" name="mainwp_setting_emails_type" value="<?php echo esc_html( $type ); ?>" />
286 + <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-email-tokens-info-message' ) ) : ?>
287 + <div class="ui info message">
288 + <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-updates-message"></i>
289 + <?php
290 + /* translators: 1: Opening anchor tag for Boilerplate, 2: Closing anchor tag, 3: Opening anchor tag for Reports, 4: Closing anchor tag */
291 + printf( esc_html__( '%1$sBoilerplate%2$s and %3$sReports%4$s extensions tokens are supported in the email settings and templates if Extensions are in use.', 'mainwp' ), '<a href="https://mainwp.com/extension/boilerplate/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://mainwp.com/extension/pro-reports/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe.
292 + ?>
293 + </div>
294 + <?php endif; ?>
295 + <h3 class="ui header">
296 + <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-email-' . esc_attr( $type ) ); ?>
297 + <?php echo esc_html( $title ); ?></h3>
298 + <div class="sub header"><?php echo esc_html( $email_description ); ?></h3></div>
299 + <div class="ui divider"></div>
300 + <?php
301 + $def_val = MainWP_Settings_Indicator::get_defaults_email_settings_value( $type, 'disable' );
302 + ?>
303 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-email-<?php echo esc_attr( $type ); ?>" default-indi-value="<?php echo esc_attr( $def_val ); ?>">
304 + <label class="six wide column middle aligned">
305 + <?php
306 + MainWP_Settings_Indicator::render_not_default_email_settings_indicator( $type, 'disable', (int) $options['disable'] );
307 + esc_html_e( 'Enable', 'mainwp' );
308 + ?>
309 + </label>
310 + <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable this email notification.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
311 + <input type="checkbox" inverted-value="1" class="settings-field-value-change-handler" name="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][disable]" id="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][disable]" <?php echo ( 0 === (int) $options['disable'] ) ? 'checked="true"' : ''; ?>/>
312 + </div>
313 + </div>
314 + <?php
315 + $def_val = MainWP_Settings_Indicator::get_defaults_email_settings_value( $type, 'recipients' );
316 + ?>
317 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-email-<?php echo esc_attr( $type ); ?>" default-indi-value="<?php echo esc_attr( $def_val ); ?>">
318 + <label class="six wide column middle aligned">
319 + <?php
320 + MainWP_Settings_Indicator::render_not_default_email_settings_indicator( $type, 'recipients', $options['recipients'] );
321 + esc_html_e( 'Recipient(s)', 'mainwp' );
322 + ?>
323 + </label>
324 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'You can add multiple emails by separating them with comma.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
325 + <input type="text" class="settings-field-value-change-handler" name="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][recipients]" id="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][recipients]" value="<?php echo esc_html( $options['recipients'] ); ?>"/>
326 + </div>
327 + </div>
328 + <?php
329 + $def_val = MainWP_Settings_Indicator::get_defaults_email_settings_value( $type, 'subject' );
330 + ?>
331 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-email-<?php echo esc_attr( $type ); ?>" default-indi-value="<?php echo esc_attr( $def_val ); ?>">
332 + <label class="six wide column middle aligned">
333 + <?php
334 + MainWP_Settings_Indicator::render_not_default_email_settings_indicator( $type, 'subject', $options['subject'] );
335 + esc_html_e( 'Subject', 'mainwp' );
336 + ?>
337 + </label>
338 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enter the email subject.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
339 + <input type="text" class="settings-field-value-change-handler" name="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][subject]" id="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][subject]" value="<?php echo esc_html( $options['subject'] ); ?>"/>
340 + </div>
341 + </div>
342 + <?php
343 + $def_val = MainWP_Settings_Indicator::get_defaults_email_settings_value( $type, 'heading' );
344 + ?>
345 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-email-<?php echo esc_attr( $type ); ?>" default-indi-value="<?php echo esc_attr( $def_val ); ?>">
346 + <label class="six wide column middle aligned">
347 + <?php
348 + MainWP_Settings_Indicator::render_not_default_email_settings_indicator( $type, 'heading', $options['heading'] );
349 + esc_html_e( 'Email heading', 'mainwp' );
350 + ?>
351 + </label>
352 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enter the email heading.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
353 + <input type="text" class="settings-field-value-change-handler" name="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][heading]" id="mainwp_settingEmails[<?php echo esc_html( $type ); ?>][heading]" value="<?php echo esc_html( $options['heading'] ); ?>"/>
354 + </div>
355 + </div>
356 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-email-<?php echo esc_attr( $type ); ?>" >
357 + <?php
358 + $templ = MainWP_Notification_Template::get_template_name_by_notification_type( $type );
359 + $overrided = MainWP_Notification_Template::instance()->is_overrided_template( $type );
360 + ?>
361 + <label class="six wide column middle aligned">
362 + <?php
363 + MainWP_Settings_Indicator::render_not_default_email_settings_indicator( $type, 'overrided', (int) $overrided );
364 + esc_html_e( 'HTML template', 'mainwp' );
365 + ?>
366 + </label>
367 + <div class="ui ten wide column" data-tooltip="<?php esc_attr_e( 'Manage the email HTML template.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
368 + <?php
369 + /**
370 + *
371 + * Use mainwp_notification_template_copy_message instead.
372 + *
373 + * @deprecated Since v4.3.
374 + */
375 + $copy_message = apply_filters( 'minwp_notification_template_copy_message', '', $templ, $type, $overrided );
376 + /**
377 + *
378 + * Filter mainwp_notification_template_copy_message.
379 + *
380 + * @since v4.3
381 + */
382 + $copy_message = apply_filters( 'mainwp_notification_template_copy_message', $copy_message, $templ, $type, $overrided );
383 + if ( empty( $copy_message ) ) {
384 + $copy_message = $overrided ? esc_html__( 'This template has been overridden and can be found in:', 'mainwp' ) . ' <code>wp-content/uploads/mainwp/templates/' . esc_html( $templ ) . '</code>' : esc_html__( 'To override and edit this email template copy:', 'mainwp' ) . ' <code>mainwp/templates/' . esc_html( $templ ) . '</code> ' . esc_html__( 'to the folder:', 'mainwp' ) . ' <code>wp-content/uploads/mainwp/templates/' . esc_html( $templ ) . '</code>';
385 + }
386 + echo $copy_message; // phpcs:ignore WordPress.Security.EscapeOutput
387 + ?>
388 + </div>
389 + </div>
390 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-email-<?php echo esc_attr( $type ); ?>" >
391 + <label class="six wide column middle aligned"></label>
392 + <div class="ui ten wide column" data-tooltip="<?php esc_attr_e( 'Manage the email HTML template.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
393 + <?php if ( $overrided ) : ?>
394 + <a href="<?php echo esc_url( wp_nonce_url( 'admin.php?page=SettingsEmail&edit-email=' . $type, 'delete-email-template' ) ); ?>" onclick="mainwp_confirm('<?php echo esc_js( 'Are you sure you want to delete this template file?', 'mainwp' ); ?>', function(){ window.location = jQuery('a#email-delete-template').attr('href');}); return false;" id="email-delete-template" class="ui button"><?php esc_html_e( 'Return to Default Template', 'mainwp' ); ?></a>
395 + <?php else : ?>
396 + <a href="<?php echo esc_url( wp_nonce_url( 'admin.php?page=SettingsEmail&edit-email=' . $type, 'copy-email-template' ) ); ?>" class="ui button"><?php esc_html_e( 'Copy file to uploads', 'mainwp' ); ?></a>
397 + <?php endif; ?>
398 + <?php if ( $overrided ) : ?>
399 + <a href="javascript:void(0)" class="ui button" onclick="mainwp_view_template('<?php echo esc_js( $type ); ?>', true ); return false;"><?php esc_html_e( 'Edit Template', 'mainwp' ); ?></a>
400 + <?php else : ?>
401 + <a href="javascript:void(0)" class="ui button" onclick="mainwp_view_template('<?php echo esc_js( $type ); ?>', true ); return false;"><?php esc_html_e( 'View Template', 'mainwp' ); ?></a>
402 + <?php endif; ?>
403 + </div>
404 + </div>
405 + <div class="ui divider"></div>
406 + <a href="admin.php?page=SettingsEmail" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
407 + <input type="submit" name="submit" id="submit" class="ui green big button right floated" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
408 + <div style="clear:both"></div>
409 + </form>
410 + </div>
411 + </div>
412 + <?php MainWP_Manage_Sites_View::render_edit_template( $type ); ?>
413 + <?php
414 + }
412 415
413 - /**
414 - * Get email notification types.
415 - *
416 - * @param string $type Email notification type.
417 - *
418 - * @return mixed Notification types.
419 - */
420 - public static function get_notification_types( $type = '' ) {
421 - $types = array(
422 - 'daily_digest' => esc_html__( 'Daily Digest Email', 'mainwp' ),
423 - 'uptime' => esc_html__( 'Basic Uptime Monitoring Email', 'mainwp' ),
424 - 'site_health' => esc_html__( 'Site Health Monitoring Email', 'mainwp' ),
425 - 'deactivated_license_alert' => esc_html__( 'Extension License Deactivation Notification Email', 'mainwp' ),
426 - );
427 416
428 - $enable_http_check = get_option( 'mainwp_check_http_response', 0 );
417 + /**
418 + * Get email settings description.
419 + *
420 + * @param string $type Email notification type.
421 + *
422 + * @return string $email_description Email settings Description.
423 + */
424 + public static function get_settings_desc( $type ) {
425 + $email_description = '';
426 + if ( 'daily_digest' === $type ) {
427 + $email_description = esc_html__( 'Daily notification about available updates and disconnected sites.', 'mainwp' );
428 + } elseif ( 'uptime' === $type ) {
429 + $email_description = esc_html__( 'Alert if any of your websites is down.', 'mainwp' );
430 + } elseif ( 'site_health' === $type ) {
431 + $email_description = esc_html__( 'Alert if any of your websites site health goes under the threshold.', 'mainwp' );
432 + } elseif ( 'http_check' === $type ) {
433 + $email_description = esc_html__( 'Alert if any of your websites return unexpected HTTP status after running updates.', 'mainwp' );
434 + } elseif ( 'deactivated_license_alert' === $type ) {
435 + $email_description = esc_html__( 'Receive a notification when an extension\'s license is deactivated.', 'mainwp' );
436 + } elseif ( 'auto_updates' === $type ) {
437 + $email_description = esc_html__( 'Receive a notification about auto-updates.', 'mainwp' );
438 + }
429 439
430 - if ( $enable_http_check ) {
431 - $types['http_check'] = esc_html__( 'After Updates HTTP Check Email', 'mainwp' );
432 - }
440 + $addition_desc = apply_filters( 'mainwp_notification_type_desc', '', $type );
441 + if ( ! empty( $addition_desc ) ) {
442 + $email_description = $addition_desc;
443 + }
433 444
434 - $addition_types = apply_filters( 'mainwp_notification_types', array(), $type );
435 - if ( ! empty( $addition_types ) ) {
436 - $types = array_merge( $types, $addition_types );
437 - }
445 + return $email_description;
446 + }
438 447
439 - if ( empty( $type ) ) {
440 - return $types;
441 - } else {
442 - return ( isset( $types[ $type ] ) ) ? $types[ $type ] : false;
443 - }
444 - }
448 + /**
449 + * Render the notification after the update process.
450 + *
451 + * @param int $updated Update code (copied, saved or deleted).
452 + */
453 + public static function render_update_template_message( $updated ) {
454 + switch ( (int) $updated ) {
455 + case 1:
456 + ?>
457 + <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Custom email template deleted successfully.', 'mainwp' ); ?></div>
458 + <?php
459 + break;
460 + case 2:
461 + ?>
462 + <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Email template copied successfully.', 'mainwp' ); ?></div>
463 + <?php
464 + break;
465 + case 3:
466 + ?>
467 + <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Email template updated successfully.', 'mainwp' ); ?></div>
468 + <?php
469 + break;
470 + case 31:
471 + ?>
472 + <div class="ui message yellow"><i class="close icon"></i> <?php esc_html_e( 'Email template update failed. Please try again.', 'mainwp' ); ?></div>
473 + <?php
474 + break;
475 + case 32:
476 + ?>
477 + <div class="ui message yellow"><i class="close icon"></i> <?php esc_html_e( 'Email template failed to open. Please try again.', 'mainwp' ); ?></div>
478 + <?php
479 + break;
480 + case 33:
481 + ?>
482 + <div class="ui message yellow"><i class="close icon"></i> <?php esc_html_e( 'Email template is not writable. Please try again.', 'mainwp' ); ?></div>
483 + <?php
484 + break;
485 + case 34:
486 + ?>
487 + <div class="ui message yellow"><i class="close icon"></i> <?php esc_html_e( 'The destination email template is invalid and could not be saved. Please try again.', 'mainwp' ); ?></div>
488 + <?php
489 + break;
490 + case 35:
491 + ?>
492 + <div class="ui message yellow"><i class="close icon"></i> <?php esc_html_e( 'Email template update failed. Please ensure you have theme editing permissions and try again.', 'mainwp' ); ?></div>
493 + <?php
494 + break;
495 + default:
496 + break;
497 + }
498 + }
445 499
446 - /**
447 - * Get general email notifications settings.
448 - *
449 - * @param string $type Email type.
450 - *
451 - * @see function get_notification_types()
452 - *
453 - * @return array An array containing the email settings.
454 - */
455 - public static function get_general_email_settings( $type ) {
456 - $settings = get_option( 'mainwp_settings_notification_emails', array() );
457 - if ( ! is_array( $settings ) ) {
458 - $settings = array();
459 - }
500 + /**
501 + * Get email notification types.
502 + *
503 + * @param string $type Email notification type.
504 + *
505 + * @return mixed Notification types.
506 + */
507 + public static function get_notification_types( $type = '' ) {
508 + $types = array(
509 + 'daily_digest' => esc_html__( 'Daily Digest Email', 'mainwp' ),
510 + 'auto_updates' => esc_html__( 'Auto Updates Email', 'mainwp' ),
511 + 'uptime' => esc_html__( 'Uptime Monitoring Email', 'mainwp' ),
512 + 'site_health' => esc_html__( 'Site Health Monitoring Email', 'mainwp' ),
513 + 'deactivated_license_alert' => esc_html__( 'Extension License Deactivation Notification Email', 'mainwp' ),
514 + );
460 515
461 - $options = isset( $settings[ $type ] ) ? $settings[ $type ] : array();
462 - $default = self::get_default_emails_fields( $type, '', true );
463 - return array_merge( $default, $options );
464 - }
516 + $enable_http_check = get_option( 'mainwp_check_http_response', 0 );
465 517
466 - /**
467 - * Get general notification email.
468 - *
469 - * @return string|empty recipients.
470 - */
471 - public static function get_general_email() {
472 - $gen_email_settings = self::get_general_email_settings( 'daily_digest' );
473 - return isset( $gen_email_settings['recipients'] ) ? $gen_email_settings['recipients'] : '';
474 - }
518 + if ( $enable_http_check ) {
519 + $types['http_check'] = esc_html__( 'After Updates HTTP Check Email', 'mainwp' );
520 + }
475 521
476 - /**
477 - * Update general notification email.
478 - *
479 - * @param string $emails Emails.
480 - *
481 - * @return void
482 - */
483 - public static function update_general_email( $emails ) {
484 - $emails_settings = get_option( 'mainwp_settings_notification_emails' );
485 - if ( ! is_array( $emails_settings ) ) {
486 - $emails_settings = array();
487 - }
488 - $type = 'daily_digest';
489 - $update_settings = isset( $emails_settings[ $type ] ) ? $emails_settings[ $type ] : array();
490 - $update_settings['recipients'] = $emails;
491 - $emails_settings[ $type ] = $update_settings;
492 - MainWP_Utility::update_option( 'mainwp_settings_notification_emails', $emails_settings );
493 - }
522 + $addition_types = apply_filters( 'mainwp_notification_types', array(), $type );
523 + if ( ! empty( $addition_types ) ) {
524 + $types = array_merge( $types, $addition_types );
525 + }
494 526
495 - /**
496 - * Get email settings for a single site.
497 - *
498 - * @param string $type Email type.
499 - * @param object $website Object containing the child site information.
500 - *
501 - * @return array An array containing the email settings.
502 - *
503 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_tokens_site_values()
504 - * @uses \MainWP\Dashboard\MainWP_System_Utility::replace_tokens_values()
505 - */
506 - public static function get_site_email_settings( $type, $website ) {
507 - if ( empty( $website ) || ! property_exists( $website, 'settings_notification_emails' ) ) {
508 - return array( 'disable' => 1 );
509 - }
510 - $settings = array();
511 - if ( ! empty( $website->settings_notification_emails ) ) {
512 - $settings = json_decode( $website->settings_notification_emails, true );
513 - }
527 + if ( empty( $type ) ) {
528 + return $types;
529 + } else {
530 + return ( isset( $types[ $type ] ) ) ? $types[ $type ] : false;
531 + }
532 + }
514 533
515 - if ( ! is_array( $settings ) ) {
516 - $settings = array();
517 - }
534 + /**
535 + * Get general email notifications settings.
536 + *
537 + * @param string $type Email type.
538 + *
539 + * @see function get_notification_types()
540 + *
541 + * @return array An array containing the email settings.
542 + */
543 + public static function get_general_email_settings( $type ) {
544 + $settings = get_option( 'mainwp_settings_notification_emails', array() );
545 + if ( ! is_array( $settings ) ) {
546 + $settings = array();
547 + }
518 548
519 - $options = isset( $settings[ $type ] ) ? $settings[ $type ] : array();
520 - $default = self::get_default_emails_fields( $type );
521 - $options = array_merge( $default, $options );
549 + $options = isset( $settings[ $type ] ) ? $settings[ $type ] : array();
550 + $default = static::get_default_emails_fields( $type, '', true );
551 + return array_merge( $default, $options );
552 + }
522 553
523 - if ( preg_match( '/\[[^\]]+\]/is', $options['subject'] . $options['heading'], $matches ) ) {
524 - $tokens_values = MainWP_System_Utility::get_tokens_site_values( $website );
525 - $options['subject'] = MainWP_System_Utility::replace_tokens_values( $options['subject'], $tokens_values );
526 - $options['heading'] = MainWP_System_Utility::replace_tokens_values( $options['heading'], $tokens_values );
527 - }
554 + /**
555 + * Prepare general email notifications settings.
556 + *
557 + * @param array $options Email settings.
558 + * @param object $website Site data.
559 + *
560 + * @return void.
561 + */
562 + public static function prepare_general_email_settings_for_site( &$options, $website ) {
563 + if ( is_array( $options ) && isset( $options['subject'] ) && isset( $options['heading'] ) && isset( $options['recipients'] ) ) {
564 + if ( preg_match( '/\[[^\]]+\]/is', $options['subject'] . $options['heading'], $matches ) ) {
565 + $tokens_values = MainWP_System_Utility::get_tokens_site_values( $website, true );
566 + $options['subject'] = MainWP_System_Utility::replace_tokens_values( $options['subject'], $tokens_values );
567 + $options['heading'] = MainWP_System_Utility::replace_tokens_values( $options['heading'], $tokens_values );
568 + }
528 569
529 - if ( preg_match( '/\[[^\]]+\]/is', $options['recipients'] . $options['subject'] . $options['heading'], $matches ) ) {
530 - // support boilerplate and reports tokens.
531 - $fields = array( 'recipients', 'subject', 'heading' );
532 - $options = self::replace_tokens_for_settings( $options, $fields, $website );
533 - }
570 + if ( preg_match( '/\[[^\]]+\]/is', $options['recipients'] . $options['subject'] . $options['heading'], $matches ) ) {
571 + // support boilerplate and reports tokens.
572 + $fields = array( 'recipients', 'subject', 'heading' );
573 + $options = static::replace_tokens_for_settings( $options, $fields, $website );
574 + }
575 + }
576 + }
534 577
535 - return $options;
536 - }
578 + /**
579 + * Get general notification email.
580 + *
581 + * @return string|empty recipients.
582 + */
583 + public static function get_general_email() {
584 + $gen_email_settings = static::get_general_email_settings( 'daily_digest' );
585 + return isset( $gen_email_settings['recipients'] ) ? $gen_email_settings['recipients'] : '';
586 + }
537 587
538 - /**
539 - * Get default email notifications values.
540 - *
541 - * @param string $type Email type.
542 - * @param string $field Field name.
543 - * @param bool $general General or individual site settings.
544 - *
545 - * @return array|string Email field settings value.
546 - *
547 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_notification_email()
548 - */
549 - public static function get_default_emails_fields( $type, $field = '', $general = false ) {
588 + /**
589 + * Update general notification email.
590 + *
591 + * @param string $emails Emails.
592 + *
593 + * @return void
594 + */
595 + public static function update_general_email( $emails ) {
596 + $emails_settings = get_option( 'mainwp_settings_notification_emails' );
597 + if ( ! is_array( $emails_settings ) ) {
598 + $emails_settings = array();
599 + }
600 + $type = 'daily_digest';
601 + $update_settings = isset( $emails_settings[ $type ] ) ? $emails_settings[ $type ] : array();
602 + $update_settings['recipients'] = $emails;
603 + $emails_settings[ $type ] = $update_settings;
604 + MainWP_Utility::update_option( 'mainwp_settings_notification_emails', $emails_settings );
605 + }
550 606
551 - $recipients = MainWP_System_Utility::get_notification_email();
552 - $disable = $general ? 0 : 1;
607 + /**
608 + * Get email settings for a single site.
609 + *
610 + * @param string $type Email type.
611 + * @param object $website Object containing the child site information.
612 + * @param mixed $website_status Object containing the child site status.
613 + *
614 + * @return array An array containing the email settings.
615 + *
616 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_tokens_site_values()
617 + * @uses \MainWP\Dashboard\MainWP_System_Utility::replace_tokens_values()
618 + */
619 + public static function get_site_email_settings( $type, $website, $website_status = false ) {
620 + if ( empty( $website ) || ! property_exists( $website, 'settings_notification_emails' ) ) {
621 + return array( 'disable' => 1 );
622 + }
623 + $settings = array();
624 + if ( ! empty( $website->settings_notification_emails ) ) {
625 + $settings = json_decode( $website->settings_notification_emails, true );
626 + }
553 627
554 - $default_fields = array(
555 - 'daily_digest' => array(
556 - 'disable' => $disable,
557 - 'recipients' => $recipients,
558 - 'subject' => $general ? 'Daily Digest' : '[site.name] Daily Digest',
559 - 'heading' => $general ? 'Daily Digest' : '[site.name] Daily Digest',
560 - ),
561 - 'uptime' => array(
562 - 'disable' => $disable,
563 - 'recipients' => $recipients,
564 - 'subject' => $general ? 'Uptime Monitoring' : '[site.name] Uptime Monitoring',
565 - 'heading' => $general ? 'Uptime Monitoring' : '[site.name] Uptime Monitoring',
566 - ),
567 - 'site_health' => array(
568 - 'disable' => $disable,
569 - 'recipients' => $recipients,
570 - 'subject' => $general ? 'Site Health Monitoring' : '[site.name] Site Health Monitoring',
571 - 'heading' => $general ? 'Site Health Monitoring' : '[site.name] Site Health Monitoring',
572 - ),
573 - 'http_check' => array(
574 - 'disable' => $disable,
575 - 'recipients' => $recipients,
576 - 'subject' => 'HTTP response check',
577 - 'heading' => 'Sites Check',
578 - ),
579 - 'deactivated_license_alert' => array(
580 - 'disable' => $disable,
581 - 'recipients' => $recipients,
582 - 'subject' => 'Extension License Deactivation Notification',
583 - 'heading' => 'Extension License Deactivation Notification',
584 - ),
585 - );
628 + if ( ! is_array( $settings ) ) {
629 + $settings = array();
630 + }
586 631
587 - $addition_default_fields = apply_filters( 'mainwp_default_emails_fields', array(), $recipients, $type, $field, $general );
588 - if ( ! empty( $addition_default_fields ) ) {
589 - $default_fields = array_merge( $default_fields, $addition_default_fields );
590 - }
632 + $options = isset( $settings[ $type ] ) ? $settings[ $type ] : array();
633 + $default = static::get_default_emails_fields( $type );
634 + $options = array_merge( $default, $options );
591 635
592 - if ( ! empty( $type ) && ! empty( $field ) ) {
593 - return isset( $default_fields[ $type ] ) && isset( $default_fields[ $type ][ $field ] ) ? $default_fields[ $type ][ $field ] : '';
594 - }
636 + if ( preg_match( '/\[[^\]]+\]/is', $options['subject'] . $options['heading'], $matches ) ) {
637 + $tokens_values = MainWP_System_Utility::get_tokens_site_values( $website, true, $website_status );
638 + $options['subject'] = MainWP_System_Utility::replace_tokens_values( $options['subject'], $tokens_values );
639 + $options['heading'] = MainWP_System_Utility::replace_tokens_values( $options['heading'], $tokens_values );
640 + }
595 641
596 - if ( ! empty( $type ) && empty( $field ) ) {
597 - return isset( $default_fields[ $type ] ) ? $default_fields[ $type ] : array();
598 - }
642 + if ( preg_match( '/\[[^\]]+\]/is', $options['recipients'] . $options['subject'] . $options['heading'], $matches ) ) {
643 + // support boilerplate and reports tokens.
644 + $fields = array( 'recipients', 'subject', 'heading' );
645 + $options = static::replace_tokens_for_settings( $options, $fields, $website );
646 + }
599 647
600 - return array();
601 - }
648 + return $options;
649 + }
602 650
603 - /**
604 - * Replace site tokens for settings.
605 - *
606 - * @param array $options array of fields to find and replace tokens.
607 - * @param array $fields fields names to find.
608 - * @param object $website The website.
609 - *
610 - * @return array $options array of fields.
611 - *
612 - * @uses \MainWP\Dashboard\MainWP_System_Utility::replace_tokens_values()
613 - */
614 - public static function replace_tokens_for_settings( $options, $fields, $website ) {
651 + /**
652 + * Get default email notifications values.
653 + *
654 + * @param string $type Email type.
655 + * @param string $field Field name.
656 + * @param bool $general General or individual site settings.
657 + *
658 + * @return array|string Email field settings value.
659 + *
660 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_notification_email()
661 + */
662 + public static function get_default_emails_fields( $type, $field = '', $general = false ) { // phpcs:ignore -- NOSONAR - complex.
615 663
616 - /**
617 - * Filter: mainwp_boilerplate_get_tokens
618 - *
619 - * Enables and filters the Boilerplate extension tokens.
620 - *
621 - * @param object $website Object containing the child site data.
622 - *
623 - * @since 4.1
624 - */
625 - $boilerplate_tokens = apply_filters( 'mainwp_boilerplate_get_tokens', false, $website );
664 + $recipients = MainWP_System_Utility::get_notification_email();
665 + $disable = $general ? 0 : 1;
626 666
627 - if ( is_array( $boilerplate_tokens ) ) {
628 - foreach ( $fields as $field ) {
629 - if ( isset( $options[ $field ] ) ) {
630 - $options[ $field ] = MainWP_System_Utility::replace_tokens_values( $options[ $field ], $boilerplate_tokens );
631 - }
632 - }
633 - }
667 + $default_fields = array(
668 + 'daily_digest' => array(
669 + 'disable' => $disable,
670 + 'recipients' => $recipients,
671 + 'subject' => $general ? 'Daily Digest from Your MainWP Dashboard' : '[site.name] Daily Digest from Your MainWP Dashboard',
672 + 'heading' => $general ? 'Daily Digest' : '[site.name] Daily Digest',
673 + ),
674 + 'auto_updates' => array(
675 + 'disable' => $disable,
676 + 'recipients' => $recipients,
677 + 'subject' => $general ? 'Auto Updates Notification from Your MainWP Dashboard' : '[site.name] Auto Updates Notification from Your MainWP Dashboard',
678 + 'heading' => $general ? 'Auto Updates Notification' : '[site.name] Auto Updates Notification',
679 + ),
680 + 'uptime' => array(
681 + 'disable' => $disable,
682 + 'recipients' => $recipients,
683 + 'subject' => $general ? 'Uptime Monitoring Alert from your MainWP Dashboard' : '[site.name] Uptime Monitoring Alert from your MainWP Dashboard',
684 + 'heading' => $general ? 'Uptime Monitoring' : '[site.name] Uptime Monitoring',
685 + ),
686 + 'site_health' => array(
687 + 'disable' => $disable,
688 + 'recipients' => $recipients,
689 + 'subject' => $general ? 'Site Health Monitoring Alert from Your MainWP Dashboard' : '[site.name] Site Health Monitoring Alert from Your MainWP Dashboard',
690 + 'heading' => $general ? 'Site Health Monitoring' : '[site.name] Site Health Monitoring',
691 + ),
692 + 'http_check' => array(
693 + 'disable' => $disable,
694 + 'recipients' => $recipients,
695 + 'subject' => 'HTTP response check',
696 + 'heading' => 'Sites Check',
697 + ),
698 + 'deactivated_license_alert' => array(
699 + 'disable' => $disable,
700 + 'recipients' => $recipients,
701 + 'subject' => 'Extension License Deactivation Notification from Your MainWP Dashboard',
702 + 'heading' => 'Extension License Deactivation Notification',
703 + ),
704 + );
634 705
635 - /**
636 - * Filter: mainwp_pro_reports_get_site_tokens
637 - *
638 - * Enables and filters the Pro Reports extension tokens.
639 - *
640 - * @param object $website Object containing the child site data.
641 - *
642 - * @since 4.1
643 - */
644 - $report_tokens = apply_filters( 'mainwp_pro_reports_get_site_tokens', false, $website->id );
706 + $addition_default_fields = apply_filters( 'mainwp_default_emails_fields', array(), $recipients, $type, $field, $general );
707 + if ( ! empty( $addition_default_fields ) ) {
708 + $default_fields = array_merge( $default_fields, $addition_default_fields );
709 + }
645 710
646 - if ( is_array( $report_tokens ) ) {
647 - foreach ( $fields as $field ) {
648 - if ( isset( $options[ $field ] ) ) {
649 - $options[ $field ] = MainWP_System_Utility::replace_tokens_values( $options[ $field ], $report_tokens );
650 - }
651 - }
652 - }
711 + if ( ! empty( $type ) && ! empty( $field ) ) {
712 + return isset( $default_fields[ $type ] ) && isset( $default_fields[ $type ][ $field ] ) ? $default_fields[ $type ][ $field ] : '';
713 + }
653 714
654 - /**
655 - * Filter: mainwp_client_report_get_site_tokens
656 - *
657 - * Enables and filters the Client Reports extension tokens.
658 - *
659 - * @param object $website Object containing the child site data.
660 - *
661 - * @since 4.1
662 - */
663 - $client_report_tokens = apply_filters( 'mainwp_client_report_get_site_tokens', false, $website->id );
664 - if ( is_array( $client_report_tokens ) ) {
665 - foreach ( $fields as $field ) {
666 - if ( isset( $options[ $field ] ) ) {
667 - $options[ $field ] = MainWP_System_Utility::replace_tokens_values( $options[ $field ], $client_report_tokens );
668 - }
669 - }
670 - }
715 + if ( ! empty( $type ) && empty( $field ) ) {
716 + return isset( $default_fields[ $type ] ) ? $default_fields[ $type ] : array();
717 + }
671 718
672 - return $options;
673 - }
719 + return array();
720 + }
674 721
675 - /**
676 - * Replace site tokens for content.
677 - *
678 - * @param string $content content to find and replace tokens.
679 - * @param object $website The website.
680 - *
681 - * @return string $content after replaced tokens.
682 - *
683 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_tokens_site_values()
684 - * @uses \MainWP\Dashboard\MainWP_System_Utility::replace_tokens_values()
685 - */
686 - public static function replace_tokens_for_content( $content, $website ) {
722 + /**
723 + * Replace site tokens for settings.
724 + *
725 + * @param array $options array of fields to find and replace tokens.
726 + * @param array $fields fields names to find.
727 + * @param object $website The website.
728 + *
729 + * @return array $options array of fields.
730 + *
731 + * @uses \MainWP\Dashboard\MainWP_System_Utility::replace_tokens_values()
732 + */
733 + public static function replace_tokens_for_settings( $options, $fields, $website ) { // phpcs:ignore -- NOSONAR - complex.
687 734
688 - $tokens_values = MainWP_System_Utility::get_tokens_site_values( $website );
735 + if ( null === static::$boilerplate_tokens_loaded ) {
736 + /**
737 + * Filter: mainwp_boilerplate_get_tokens
738 + *
739 + * Enables and filters the Boilerplate extension tokens.
740 + *
741 + * @param object $website Object containing the child site data.
742 + *
743 + * @since 4.1
744 + */
745 + static::$boilerplate_tokens_loaded = apply_filters( 'mainwp_boilerplate_get_tokens', false, $website );
746 + }
689 747
690 - $content = MainWP_System_Utility::replace_tokens_values( $content, $tokens_values );
748 + $boilerplate_tokens = static::$boilerplate_tokens_loaded;
691 749
692 - // if tokens existed.
693 - if ( preg_match( '/\[[^\]]+\]/is', $content, $matches ) ) {
750 + if ( is_array( $boilerplate_tokens ) ) {
751 + foreach ( $fields as $field ) {
752 + if ( isset( $options[ $field ] ) ) {
753 + $options[ $field ] = MainWP_System_Utility::replace_tokens_values( $options[ $field ], $boilerplate_tokens );
754 + }
755 + }
756 + }
694 757
695 - /** This filter is documented in ../class/class-mainwp-notification-settings.php */
696 - $boilerplate_tokens = apply_filters( 'mainwp_boilerplate_get_tokens', false, $website );
758 + if ( null === static::$report_tokens_loaded ) {
759 + /**
760 + * Filter: mainwp_pro_reports_get_site_tokens
761 + *
762 + * Enables and filters the Pro Reports extension tokens.
763 + *
764 + * @param object $website Object containing the child site data.
765 + *
766 + * @since 4.1
767 + */
768 + static::$report_tokens_loaded = apply_filters( 'mainwp_pro_reports_get_site_tokens', false, $website->id );
769 + }
697 770
698 - if ( is_array( $boilerplate_tokens ) ) {
699 - $content = MainWP_System_Utility::replace_tokens_values( $content, $boilerplate_tokens );
700 - }
771 + $report_tokens = static::$report_tokens_loaded;
701 772
702 - /** This filter is documented in ../class/class-mainwp-notification-settings.php */
703 - $report_tokens = apply_filters( 'mainwp_pro_reports_get_site_tokens', false, $website->id );
773 + if ( is_array( $report_tokens ) ) {
774 + foreach ( $fields as $field ) {
775 + if ( isset( $options[ $field ] ) ) {
776 + $options[ $field ] = MainWP_System_Utility::replace_tokens_values( $options[ $field ], $report_tokens );
777 + }
778 + }
779 + }
704 780
705 - if ( is_array( $report_tokens ) ) {
706 - $content = MainWP_System_Utility::replace_tokens_values( $content, $report_tokens );
707 - }
781 + if ( null === static::$client_report_tokens_loaded ) {
782 + /**
783 + * Filter: mainwp_client_report_get_site_tokens
784 + *
785 + * Enables and filters the Client Reports extension tokens.
786 + *
787 + * @param object $website Object containing the child site data.
788 + *
789 + * @since 4.1
790 + */
791 + static::$client_report_tokens_loaded = apply_filters( 'mainwp_client_report_get_site_tokens', false, $website->id );
792 + }
708 793
709 - /** This filter is documented in ../class/class-mainwp-notification-settings.php */
710 - $client_report_tokens = apply_filters( 'mainwp_client_report_get_site_tokens', false, $website->id );
794 + $client_report_tokens = static::$client_report_tokens_loaded;
711 795
712 - if ( is_array( $client_report_tokens ) ) {
713 - $content = MainWP_System_Utility::replace_tokens_values( $content, $client_report_tokens );
714 - }
715 - }
796 + if ( is_array( $client_report_tokens ) ) {
797 + foreach ( $fields as $field ) {
798 + if ( isset( $options[ $field ] ) ) {
799 + $options[ $field ] = MainWP_System_Utility::replace_tokens_values( $options[ $field ], $client_report_tokens );
800 + }
801 + }
802 + }
716 803
717 - return $content;
718 - }
804 + return $options;
805 + }
806 +
807 + /**
808 + * Replace site tokens for content.
809 + *
810 + * @param string $content content to find and replace tokens.
811 + * @param object $website The website.
812 + *
813 + * @return string $content after replaced tokens.
814 + *
815 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_tokens_site_values()
816 + * @uses \MainWP\Dashboard\MainWP_System_Utility::replace_tokens_values()
817 + */
818 + public static function replace_tokens_for_content( $content, $website ) {
819 +
820 + $tokens_values = MainWP_System_Utility::get_tokens_site_values( $website, true );
821 +
822 + $content = MainWP_System_Utility::replace_tokens_values( $content, $tokens_values );
823 +
824 + // if tokens existed.
825 + if ( preg_match( '/\[[^\]]+\]/is', $content, $matches ) ) {
826 +
827 + /** This filter is documented in ../class/class-mainwp-notification-settings.php */
828 + $boilerplate_tokens = apply_filters( 'mainwp_boilerplate_get_tokens', false, $website );
829 +
830 + if ( is_array( $boilerplate_tokens ) ) {
831 + $content = MainWP_System_Utility::replace_tokens_values( $content, $boilerplate_tokens );
832 + }
833 +
834 + /** This filter is documented in ../class/class-mainwp-notification-settings.php */
835 + $report_tokens = apply_filters( 'mainwp_pro_reports_get_site_tokens', false, $website->id );
836 +
837 + if ( is_array( $report_tokens ) ) {
838 + $content = MainWP_System_Utility::replace_tokens_values( $content, $report_tokens );
839 + }
840 +
841 + /** This filter is documented in ../class/class-mainwp-notification-settings.php */
842 + $client_report_tokens = apply_filters( 'mainwp_client_report_get_site_tokens', false, $website->id );
843 +
844 + if ( is_array( $client_report_tokens ) ) {
845 + $content = MainWP_System_Utility::replace_tokens_values( $content, $client_report_tokens );
846 + }
847 + }
848 +
849 + return $content;
850 + }
719 851 }