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.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 5.2.1 All 155 releases
mainwp / pages / page-mainwp-settings-indicator.php

page-mainwp-settings-indicator.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 6.2.2, at pages/page-mainwp-settings-indicator.php

286 lines 13.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Settings Indicator
4 *
5 * @package MainWP/Settings
6 */
7
8 namespace MainWP\Dashboard;
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Class MainWP_Settings_Indicator
17 *
18 * @package MainWP\Dashboard
19 */
20 class MainWP_Settings_Indicator { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
21
22
23 /**
24 * Protected static variable to hold the single instance of the class.
25 *
26 * @var mixed Default null
27 */
28 protected static $instance = null;
29
30 /**
31 * Public static varable to hold Subpages information.
32 *
33 * @var array $subPages
34 */
35 public static $saved_indicator_status = null;
36
37
38 /**
39 * Return the single instance of the class.
40 *
41 * @return mixed $instance The single instance of the class.
42 */
43 public static function get_instance() {
44 if ( is_null( static::$instance ) ) {
45 static::$instance = new self();
46 }
47 return static::$instance;
48 }
49
50
51 /**
52 * Method render_indicator().
53 *
54 * @param string $indi_type Indicator type.
55 * @param string $wrapper_cls field wrapper class.
56 * @param bool $visible Current indicator status.
57 */
58 public static function render_indicator( $indi_type = 'field', $wrapper_cls = '', $visible = true ) {
59 echo static::get_indicator( $indi_type, $wrapper_cls, $visible ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
60 }
61 /**
62 * Method get_indicator().
63 *
64 * @param bool $indi_type Indicator type.
65 * @param bool $wrapper_cls field wrapper class.
66 * @param bool $visible Current indicator status.
67 */
68 public static function get_indicator( $indi_type = 'field', $wrapper_cls = '', $visible = true ) {
69 $cls = $visible ? 'visible-indicator' : '';
70 if ( 'header' === $indi_type ) {
71 return '<i style="display:none;" field-indicator-wrapper-class="' . esc_html( $wrapper_cls ) . '" class="ui circle icon tiny yellow settings-field-header-indicator ' . $cls . ' "></i>';
72 } else {
73 return '<span data-tooltip="' . esc_attr__( 'Changed from default', 'mainwp' ) . '" data-variation="mini" data-position="top center" data-inverted=""><i class="ui circle icon tiny yellow settings-field-icon-indicator ' . $cls . '"></i></span>';
74 }
75 }
76
77 /**
78 * Method render_not_default_indicator().
79 *
80 * @param string $field setting field to check.
81 * @param mixed $current_value setting current value.
82 * @param bool $render_indi to render indication.
83 * @param mixed $default_val default value directly.
84 */
85 public static function render_not_default_indicator( $field, $current_value, $render_indi = true, $default_val = null ) {
86 $indi_value = static::get_defaults_value( $field );
87
88 if ( null !== $default_val ) {
89 $indi_value = $default_val;
90 }
91
92 $visible = false;
93 if ( ( 'none_preset_value' !== $field && $current_value !== $indi_value ) || ( 'none_preset_value' === $field && ! empty( $current_value ) ) ) {
94 $visible = true;
95 }
96 $indi = static::get_indicator( 'field', '', $visible );
97 $indi = apply_filters( 'mainwp_default_settings_indicator', $indi, $field, $indi_value, $current_value, $render_indi, $default_val );
98 if ( $render_indi ) {
99 echo $indi; //phpcs:ignore -- ok.
100 }
101 return $indi;
102 }
103
104 /**
105 * Method render_not_default_email_settings_indicator().
106 *
107 * @param string $type setting type to get default value.
108 * @param string $field setting field to check.
109 * @param mixed $current_value setting current value.
110 * @param bool $general general setting.
111 * @param bool $render_indi to render indication.
112 */
113 public static function render_not_default_email_settings_indicator( $type, $field, $current_value, $general = true, $render_indi = true ) {
114 $def = static::get_defaults_email_settings_value( $type, $field, $general );
115 $visible = false;
116 if ( null !== $def && $current_value !== $def ) {
117 $visible = true;
118 }
119 $indi = static::get_indicator( 'field', '', $visible );
120 $indi = apply_filters( 'mainwp_default_settings_indicator', $indi, $field, $def, $current_value, $render_indi, $type );
121 if ( $render_indi ) {
122 echo $indi; //phpcs:ignore -- ok.
123 }
124 return $indi;
125 }
126
127 /**
128 * Method get_defaults_value().
129 *
130 * @param string $field setting field to get default value.
131 */
132 public static function get_defaults_value( $field = 'all' ) {
133 $defauls_currency_settings = is_callable( '\MainWP\Dashboard\Module\CostTracker\Cost_Tracker_Utility::default_currency_settings' ) ? \MainWP\Dashboard\Module\CostTracker\Cost_Tracker_Utility::default_currency_settings() : array();
134 $defaults = array(
135 'none_preset_value' => '',
136 'mainwp_frequencyDailyUpdate' => 2,
137 'date_format' => 'F j, Y',
138 'time_format' => 'g:i a',
139 'mainwp_sidebarPosition' => 1,
140 'mainwp_hide_update_everything' => 0,
141 'show_default_widgets' => 'all',
142 'mainwp_pluginAutomaticDailyUpdate' => 0,
143 'mainwp_themeAutomaticDailyUpdate' => 0,
144 'mainwp_automaticDailyUpdate' => 0,
145 'mainwp_delay_autoupdate' => 1,
146 'mainwp_disable_update_confirmations' => 0,
147 'mainwp_show_language_updates' => 1,
148 'mainwp_check_http_response' => 0,
149 'mainwp_backup_before_upgrade' => 0,
150 'mainwp_backup_before_upgrade_days' => 7,
151 'mainwp_numberdays_Outdate_Plugin_Theme' => 365,
152 'mainwp_disableSitesHealthMonitoring' => 1,
153 'mainwp_sitehealthThreshold' => 80,
154 'mainwp_enableLegacyBackupFeature' => 0,
155 'mainwp_backupsOnServer' => 1,
156 'mainwp_backupOnExternalSources' => 1,
157 'mainwp_archiveFormat' => 'tar.gz',
158 'mainwp_options_loadFilesBeforeZip' => 1,
159 'mainwp_maximumFileDescriptorsAuto' => 1,
160 'mainwp_maximumFileDescriptors' => 155,
161 'mainwp_notificationOnBackupFail' => 1,
162 'mainwp_notificationOnBackupStart' => 1,
163 'mainwp_chunkedBackupTasks' => 1,
164 'mainwp_maximumRequests' => 4,
165 'mainwp_minimumDelay' => 200,
166 'mainwp_maximumIPRequests' => 1,
167 'mainwp_minimumIPDelay' => 1000,
168 'mainwp_maximumSyncRequests' => 8,
169 'mainwp_maximumInstallUpdateRequests' => 3,
170 'mainwp_maximum_uptime_monitoring_requests' => 10,
171 'mainwp_optimize' => 1,
172 'mainwp_wp_cron' => 1,
173 'mainwp_sslVerifyCertificate' => 1,
174 'mainwp_verify_connection_method' => 1,
175 'mainwp_connect_signature_algo' => defined( 'OPENSSL_ALGO_SHA256' ) ? (int) OPENSSL_ALGO_SHA256 : 1,
176 'mainwp_forceUseIPv4' => 0,
177 'mainwp_module_log_enabled' => 1,
178 'mainwp_selected_theme' => 'default',
179 'mainwp_enable_guided_tours' => 0,
180 'mainwp_enable_guided_video' => 0,
181 'mainwp_enable_guided_chatbase' => 0,
182 'mainwp_site_backup_before_upgrade' => 2,
183 'mainwp_site_suspended_site' => 0,
184 'mainwp_site_automatic_update' => 0,
185 'mainwp_site_is_ignoreCoreUpdates' => 0,
186 'mainwp_site_is_ignorePluginUpdates' => 0,
187 'mainwp_site_is_ignoreThemeUpdates' => 0,
188 'mainwp_site_is_ignore_trans_updates' => 0,
189 'mainwp_site_monitoring_notification_emails' => '',
190 'mainwp_site_disable_health_check' => 0,
191 'mainwp_site_verify_certificate' => 2,
192 'mainwp_site_ssl_version' => 0,
193 'mainwp_site_verify_method' => 3,
194 'mainwp_site_signature_algo' => 9999, // Use global setting.
195 'mainwp_site_force_use_ipv4' => 2, // Use global setting.
196 'mainwp_site_http_user' => '',
197 'mainwp_site_http_pass' => '',
198 'mainwp_site_client_id' => 0,
199 'mainwp_timeDailyUpdate' => '',
200 'cost_tracker_currency_selected' => 'USD',
201 'cost_tracker_currency_position' => is_array( $defauls_currency_settings ) && isset( $defauls_currency_settings['currency_position'] ) ? $defauls_currency_settings['currency_position'] : null,
202 'cost_tracker_thousand_separator' => is_array( $defauls_currency_settings ) && isset( $defauls_currency_settings['thousand_separator'] ) ? $defauls_currency_settings['thousand_separator'] : null,
203 'cost_tracker_decimal_separator' => is_array( $defauls_currency_settings ) && isset( $defauls_currency_settings['decimal_separator'] ) ? $defauls_currency_settings['decimal_separator'] : null,
204 'cost_tracker_decimals' => is_array( $defauls_currency_settings ) && isset( $defauls_currency_settings['decimals'] ) ? (int) $defauls_currency_settings['decimals'] : null,
205 'mainwp_frequency_AutoUpdate' => 'daily',
206 'mainwp_dayinweek_AutoUpdate' => 0,
207 'mainwp_dayinmonth_AutoUpdate' => 1,
208 'mainwp_time_AutoUpdate' => '00:00',
209 'mainwp_edit_monitor_up_status_codes' => 'useglobal',
210 'mainwp_edit_monitor_maxretries' => -1, // use global.
211 'mainwp_edit_monitor_maxretries_global' => 1,
212 'mainwp_edit_monitor_monitoring_emails' => '',
213 'mainwp_check_http_response_method' => 'head',
214 'mainwp_warm_cache_pages_ttl' => 10,
215 'mainwp_module_log_child_activities_ttl' => 7,
216 );
217
218 if ( 'all' === $field ) {
219 return $defaults;
220 }
221 return isset( $defaults[ $field ] ) ? ( $defaults[ $field ] ) : null;
222 }
223
224
225 /**
226 * Method get_defaults_email_settings_value().
227 *
228 * @param string $type setting type to get default value.
229 * @param string $field setting field to get default value.
230 * @param bool $general general setting.
231 */
232 public static function get_defaults_email_settings_value( $type, $field, $general = true ) {
233 $recipients = MainWP_System_Utility::get_notification_email();
234 $disable = $general ? 0 : 1;
235
236 $defaults = array(
237 'daily_digest' => array(
238 'disable' => $disable,
239 'recipients' => $recipients,
240 'subject' => $general ? 'Daily Digest from Your MainWP Dashboard' : '[site.name] Daily Digest from Your MainWP Dashboard',
241 'heading' => $general ? 'Daily Digest' : '[site.name] Daily Digest',
242 'overrided' => 0,
243 ),
244 'uptime' => array(
245 'disable' => $disable,
246 'recipients' => $recipients,
247 'subject' => $general ? 'Uptime Monitoring Alert from your MainWP Dashboard' : '[site.name] Uptime Monitoring Alert from your MainWP Dashboard',
248 'heading' => $general ? 'Uptime Monitoring' : '[site.name] Uptime Monitoring',
249 'overrided' => 0,
250 ),
251 'site_health' => array(
252 'disable' => $disable,
253 'recipients' => $recipients,
254 'subject' => $general ? 'Site Health Monitoring Alert from Your MainWP Dashboard' : '[site.name] Site Health Monitoring Alert from Your MainWP Dashboard',
255 'heading' => $general ? 'Site Health Monitoring' : '[site.name] Site Health Monitoring',
256 'overrided' => 0,
257 ),
258 'http_check' => array(
259 'disable' => $disable,
260 'recipients' => $recipients,
261 'subject' => 'HTTP response check',
262 'heading' => 'Sites Check',
263 'overrided' => 0,
264 ),
265 'deactivated_license_alert' => array(
266 'disable' => $disable,
267 'recipients' => $recipients,
268 'subject' => 'Extension License Deactivation Notification from Your MainWP Dashboard',
269 'heading' => 'Extension License Deactivation Notification',
270 'overrided' => 0,
271 ),
272 );
273
274 $addition_default_fields = apply_filters( 'mainwp_default_emails_fields', array(), $recipients, $type, $field, $general );
275 if ( ! empty( $addition_default_fields && is_array( $addition_default_fields ) ) ) {
276 $defaults = array_merge( $defaults, $addition_default_fields );
277 }
278
279 if ( isset( $defaults[ $type ] ) && 'overrided' === $field ) {
280 return 0; // for additions.
281 }
282
283 return isset( $defaults[ $type ] ) && isset( $defaults[ $type ][ $field ] ) ? $defaults[ $type ][ $field ] : null;
284 }
285 }
286