> Settings subpages. */ private static function get_subpages() { if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { return static::$subPages; } /** * Settings Subpages * * Filters subpages for the Settings page. * * @since Unknown */ $sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-settings', array( array() ), '4.0.7.2', 'mainwp_getsubpages_settings' ); // @deprecated Use 'mainwp_getsubpages_settings' instead. NOSONAR - not IP. static::$subPages = apply_filters( 'mainwp_getsubpages_settings', $sub_pages ); return is_array( static::$subPages ) ? static::$subPages : array(); } /** * Get the built-in Settings pages used across menu registration and navigation rendering. * * @return array> Settings page definitions. */ private static function get_core_pages() { $pages = array( array( 'slug' => 'Settings', 'page_title' => __( 'Settings Global options', 'mainwp' ), 'menu_title' => ' ' . esc_html__( 'Settings', 'mainwp' ) . '', 'nav_title' => esc_html__( 'General Settings', 'mainwp' ), 'callback' => array( static::get_class_name(), 'render' ), 'active_keys' => array( '', 'Settings' ), ), array( 'slug' => 'MainWPTools', 'page_title' => __( 'Tools', 'mainwp' ), 'menu_title' => '
' . esc_html__( 'Tools', 'mainwp' ) . '
', 'nav_title' => esc_html__( 'Tools', 'mainwp' ), 'callback' => array( static::get_class_name(), 'render_mainwp_tools' ), 'active_keys' => array( 'MainWPTools' ), ), array( 'slug' => 'CostTrackerSettings', 'page_title' => esc_html__( 'Cost Tracker Settings', 'mainwp' ), 'menu_title' => '
' . esc_html__( 'Cost Tracker', 'mainwp' ) . '
', 'nav_title' => esc_html__( 'Cost Tracker Settings', 'mainwp' ), 'callback' => array( Cost_Tracker_Settings::get_instance(), 'render_settings_page' ), 'active_keys' => array( 'CostTrackerSettings' ), ), array( 'slug' => 'SettingsAdvanced', 'page_title' => __( 'Advanced Options', 'mainwp' ), 'menu_title' => '
' . esc_html__( 'Advanced Options', 'mainwp' ) . '
', 'nav_title' => esc_html__( 'Advanced Settings', 'mainwp' ), 'callback' => array( static::get_class_name(), 'render_advanced' ), 'active_keys' => array( 'Advanced', 'SettingsAdvanced' ), ), array( 'slug' => 'MonitoringSettings', 'page_title' => __( 'Monitoring Options', 'mainwp' ), 'menu_title' => '
' . esc_html__( 'Monitoring Options', 'mainwp' ) . '
', 'nav_title' => esc_html__( 'Monitoring Settings', 'mainwp' ), 'callback' => array( static::get_class_name(), 'render_monitoring' ), 'active_keys' => array( 'Monitoring', 'MonitoringSettings' ), ), array( 'slug' => 'SettingsEmail', 'page_title' => __( 'Email Settings', 'mainwp' ), 'menu_title' => '
' . esc_html__( 'Email Settings', 'mainwp' ) . '
', 'nav_title' => esc_html__( 'Email Settings', 'mainwp' ), 'callback' => array( static::get_class_name(), 'render_email_settings' ), 'active_keys' => array( 'Emails', 'SettingsEmail' ), ), array( 'slug' => 'PremiumUpdates', 'page_title' => __( 'Premium Updates', 'mainwp' ), 'menu_title' => '
' . esc_html__( 'Premium Updates', 'mainwp' ) . '
', 'nav_title' => esc_html__( 'Premium Updates', 'mainwp' ), 'callback' => array( MainWP_Settings_Premium_Updates::get_class_name(), 'render' ), 'active_keys' => array( 'Premium', 'PremiumUpdates' ), ), ); $visible_pages = array(); foreach ( $pages as $page ) { if ( 'Settings' !== $page['slug'] && MainWP_Menu::is_disable_menu_item( 3, $page['slug'] ) ) { continue; } $visible_pages[] = $page; } return $visible_pages; } /** * Convert a navigation href into a usable URL. * * @param string $href Navigation href. * * @return string Navigation URL. */ private static function get_navigation_item_url( $href ) { $href = trim( wp_specialchars_decode( (string) $href, ENT_QUOTES ) ); if ( empty( $href ) ) { return ''; } if ( preg_match( '/^https?:\/\//i', $href ) ) { return $href; } return admin_url( ltrim( $href, '/' ) ); } /** * Get dynamic Settings subpage items using the legacy left-menu normalization path. * * @return array> Settings navigation items. */ private static function get_filtered_subpage_navigation_items() { $menu_items = array(); $core_slugs = array(); foreach ( static::get_navigation_items( 'left_menu_core' ) as $item ) { $core_slugs[ $item['slug'] ] = true; $menu_items[] = array( 'title' => $item['title'], 'parent_key' => 'Settings', 'href' => $item['href'], 'slug' => $item['slug'], 'right' => '', 'before_title' => isset( $item['before_title'] ) ? $item['before_title'] : '', ); } MainWP_Menu::init_subpages_left_menu( static::get_subpages(), $menu_items, 'Settings', 'Settings' ); $items = array(); foreach ( $menu_items as $menu_item ) { if ( empty( $menu_item['slug'] ) || empty( $menu_item['title'] ) || empty( $menu_item['href'] ) ) { continue; } if ( isset( $core_slugs[ $menu_item['slug'] ] ) ) { continue; } if ( isset( $menu_item['item_slug'] ) ) { if ( MainWP_Menu::is_disable_menu_item( 3, $menu_item['item_slug'] ) ) { continue; } } elseif ( MainWP_Menu::is_disable_menu_item( 3, $menu_item['slug'] ) ) { continue; } $active_slug = 0 === strpos( $menu_item['slug'], 'Settings' ) ? substr( $menu_item['slug'], strlen( 'Settings' ) ) : $menu_item['slug']; $item = array( 'slug' => $menu_item['slug'], 'title' => $menu_item['title'], 'href' => $menu_item['href'], 'active_keys' => array( $active_slug, $menu_item['slug'] ), 'menu_hidden' => false, ); if ( ! empty( $menu_item['before_title'] ) ) { $item['before_title'] = $menu_item['before_title']; } if ( isset( $menu_item['item_slug'] ) ) { $item['item_slug'] = $menu_item['item_slug']; } $items[] = $item; } return $items; } /** * Get the Settings navigation items. * * @return array> Settings navigation items. */ public static function get_navigation_items( $context = 'default' ) { $core_items = array(); $dynamic_items = array(); $items = array(); foreach ( static::get_core_pages() as $page ) { $core_items[ $page['slug'] ] = array( 'slug' => $page['slug'], 'title' => $page['nav_title'], 'href' => 'admin.php?page=' . $page['slug'], 'active_keys' => $page['active_keys'], 'menu_hidden' => false, ); } if ( 'command_palette' === $context ) { $dynamic_items = static::get_filtered_subpage_navigation_items(); } else { foreach ( static::get_subpages() as $subPage ) { if ( empty( $subPage['slug'] ) || MainWP_Menu::is_disable_menu_item( 3, 'Settings' . $subPage['slug'] ) ) { continue; } $item = array( 'slug' => 'Settings' . $subPage['slug'], 'title' => $subPage['title'], 'href' => ! empty( $subPage['href'] ) ? $subPage['href'] : 'admin.php?page=Settings' . $subPage['slug'], 'active_keys' => array( $subPage['slug'], 'Settings' . $subPage['slug'] ), 'menu_hidden' => ! empty( $subPage['menu_hidden'] ), ); if ( ! empty( $subPage['before_title'] ) ) { $item['before_title'] = $subPage['before_title']; } if ( isset( $subPage['class'] ) ) { $item['class'] = $subPage['class']; } if ( isset( $subPage['item_slug'] ) ) { $item['item_slug'] = $subPage['item_slug']; } $dynamic_items[] = $item; } } $base_order = array( 'Settings', 'SettingsAdvanced', 'MonitoringSettings', 'SettingsEmail', 'PremiumUpdates' ); if ( in_array( $context, array( 'left_menu', 'left_menu_core' ), true ) ) { $base_order[] = 'MainWPTools'; $base_order[] = 'CostTrackerSettings'; } else { $base_order[] = 'CostTrackerSettings'; } foreach ( $base_order as $slug ) { if ( isset( $core_items[ $slug ] ) ) { $items[] = $core_items[ $slug ]; } } if ( 'left_menu_core' !== $context ) { $items = array_merge( $items, $dynamic_items ); } if ( ! in_array( $context, array( 'left_menu', 'left_menu_core' ), true ) && isset( $core_items['MainWPTools'] ) ) { $items[] = $core_items['MainWPTools']; } return $items; } /** * Get the Settings command palette items. * * @return array> Command palette item definitions. */ public static function get_command_palette_items() { $items = array(); foreach ( static::get_navigation_items( 'command_palette' ) as $item ) { if ( ! empty( $item['menu_hidden'] ) ) { continue; } $path_title = $item['title']; $path_titles = array( esc_html__( 'Settings', 'mainwp' ), $path_title ); if ( ! empty( $item['before_title'] ) ) { $path_title = trim( wp_strip_all_tags( $item['before_title'] ) . ' ' . $item['title'] ); $path_titles[1] = $path_title; } if ( 'Settings' === $item['slug'] ) { $path_titles[1] = esc_html__( 'General Settings', 'mainwp' ); } $items[] = array( 'slug' => $item['slug'], 'href' => $item['href'], 'path_titles' => $path_titles, ); } return $items; } /** Run the export_sites method that exports the Child Sites .csv file */ public static function admin_init() { // phpcs:ignore -- NOSONAR - complex. static::export_sites(); if ( isset( $_GET['clearActivationData'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'clear_activation_data' ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized delete_option( 'mainwp_extensions_api_username' ); delete_option( 'mainwp_extensions_api_password' ); delete_option( 'mainwp_extensions_api_save_login' ); delete_option( 'mainwp_extensions_plan_info' ); MainWP_Keys_Manager::instance()->update_key_value( 'mainwp_extensions_master_api_key', false ); $new_extensions = array(); $extensions = get_option( 'mainwp_extensions', array() ); if ( is_array( $extensions ) ) { foreach ( $extensions as $ext ) { if ( isset( $ext['api'] ) && isset( $ext['apiManager'] ) && ! empty( $ext['apiManager'] ) ) { if ( isset( $ext['api_key'] ) ) { $ext['api_key'] = ''; } if ( isset( $ext['activation_email'] ) ) { $ext['activation_email'] = ''; } if ( isset( $ext['activated_key'] ) ) { $ext['activated_key'] = 'Deactivated'; } $act_info = MainWP_Api_Manager::instance()->get_activation_info( $ext['api'] ); if ( isset( $act_info['api_key'] ) ) { $act_info['api_key'] = ''; } if ( isset( $act_info['activation_email'] ) ) { $act_info['activation_email'] = ''; } if ( isset( $act_info['activated_key'] ) ) { $act_info['activated_key'] = 'Deactivated'; } MainWP_Api_Manager::instance()->set_activation_info( $ext['api'], $act_info ); } $new_extensions[] = $ext; } } MainWP_Utility::update_option( 'mainwp_extensions', $new_extensions ); update_option( 'mainwp_extensions_all_activation_cached', '' ); wp_safe_redirect( esc_url( admin_url( 'admin.php?page=MainWPTools' ) ) ); die(); } } /** * Instantiate the Settings Menu. * * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() */ public static function init_menu() { foreach ( static::get_core_pages() as $page ) { add_submenu_page( 'mainwp_tab', $page['page_title'], $page['menu_title'], 'read', $page['slug'], $page['callback'] ); } foreach ( static::get_subpages() as $subPage ) { if ( empty( $subPage['slug'] ) || MainWP_Menu::is_disable_menu_item( 3, 'Settings' . $subPage['slug'] ) ) { continue; } add_submenu_page( 'mainwp_tab', $subPage['title'], '
' . $subPage['title'] . '
', 'read', 'Settings' . $subPage['slug'], $subPage['callback'] ); } } /** * Instantiate Settings SubPages Menu. * * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() */ public static function init_subpages_menu() { ?> esc_html__( 'Settings', 'mainwp' ), 'parent_key' => 'mainwp_tab', 'slug' => 'Settings', 'href' => 'admin.php?page=Settings', 'icon' => '', ), 0 ); $init_sub_subleftmenu = array(); foreach ( static::get_navigation_items( 'left_menu_core' ) as $item ) { $init_sub_subleftmenu[] = array( 'title' => $item['title'], 'parent_key' => 'Settings', 'href' => $item['href'], 'slug' => $item['slug'], 'right' => '', 'before_title' => isset( $item['before_title'] ) ? $item['before_title'] : '', ); } if ( empty( $subPages ) ) { $subPages = static::get_subpages(); } MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'Settings', 'Settings' ); foreach ( $init_sub_subleftmenu as $item ) { if ( isset( $item['item_slug'] ) ) { if ( MainWP_Menu::is_disable_menu_item( 3, $item['item_slug'] ) ) { continue; } } elseif ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) { continue; } MainWP_Menu::add_left_menu( $item, 2 ); } } /** * Render Page Header. * * @param string $shownPage The page slug shown at this moment. * * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() * @uses \MainWP\Dashboard\MainWP_UI::render_top_header() * @uses \MainWP\Dashboard\MainWP_UI::render_page_navigation() */ public static function render_header( $shownPage = '' ) { // phpcs:ignore -- NOSONAR - complex. $params = array( 'title' => esc_html__( 'MainWP Settings', 'mainwp' ), ); MainWP_UI::render_top_header( $params ); $renderItems = array(); foreach ( static::get_navigation_items() as $item ) { $render_item = array( 'title' => $item['title'], 'href' => $item['href'], 'active' => in_array( $shownPage, $item['active_keys'], true ), ); if ( ! empty( $item['before_title'] ) ) { $render_item['before_title'] = $item['before_title']; } if ( isset( $item['class'] ) ) { $render_item['class'] = $item['class']; } $renderItems[] = $render_item; } MainWP_UI::render_page_navigation( $renderItems, 'nav_mainwp_settings' ); } /** * Close the HTML container. */ public static function render_footer() { echo ''; } /** * Method handle_settings_post(). * * This class handles the $_POST of Settings Options. * * @uses MainWP_DB::instance() * @uses MainWP_Utility::update_option() * * @return boolean True|False Posts On True. * * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension() * @uses \MainWP\Dashboard\MainWP_DB_Common::update_user_extension() * @uses \MainWP\Dashboard\MainWP_System_Utility::is_admin() * @uses \MainWP\Dashboard\MainWP_Utility::update_option() */ public static function handle_settings_post() { // phpcs:ignore -- NOSONAR - complex. if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'Settings' ) ) { $userExtension = MainWP_DB_Common::instance()->get_user_extension(); $userExtension->pluginDir = ''; MainWP_DB_Common::instance()->update_user_extension( $userExtension ); if ( MainWP_System_Utility::is_admin() ) { $old_settings = self::get_all_settings_values(); /** * Action: mainwp_before_save_general_settings * * Fires before general settings save. * * @since 4.1 */ do_action( 'mainwp_before_save_general_settings', $_POST ); $val = ( ! isset( $_POST['mainwp_pluginAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_pluginAutomaticDailyUpdate'] ) ); MainWP_Utility::update_option( 'mainwp_pluginAutomaticDailyUpdate', $val ); $val = ( ! isset( $_POST['mainwp_themeAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_themeAutomaticDailyUpdate'] ) ); MainWP_Utility::update_option( 'mainwp_themeAutomaticDailyUpdate', $val ); $val = ( ! isset( $_POST['mainwp_transAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_transAutomaticDailyUpdate'] ) ); MainWP_Utility::update_option( 'mainwp_transAutomaticDailyUpdate', $val ); $val = ( ! isset( $_POST['mainwp_automaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_automaticDailyUpdate'] ) ); MainWP_Utility::update_option( 'mainwp_automaticDailyUpdate', $val ); $val = ( ! isset( $_POST['mainwp_show_language_updates'] ) ? 0 : 1 ); MainWP_Utility::update_option( 'mainwp_show_language_updates', $val ); $val = ( ! isset( $_POST['mainwp_disable_update_confirmations'] ) ? 0 : intval( $_POST['mainwp_disable_update_confirmations'] ) ); MainWP_Utility::update_option( 'mainwp_disable_update_confirmations', $val ); $val = ( ! isset( $_POST['mainwp_backup_before_upgrade'] ) ? 0 : 1 ); MainWP_Utility::update_option( 'mainwp_backup_before_upgrade', $val ); $val = ( ! isset( $_POST['mainwp_backup_before_upgrade_days'] ) ? 7 : intval( $_POST['mainwp_backup_before_upgrade_days'] ) ); MainWP_Utility::update_option( 'mainwp_backup_before_upgrade_days', $val ); if ( is_plugin_active( 'mainwp-comments-extension/mainwp-comments-extension.php' ) ) { MainWP_Utility::update_option( 'mainwp_maximumComments', isset( $_POST['mainwp_maximumComments'] ) ? intval( $_POST['mainwp_maximumComments'] ) : 50 ); } $current_timeDailyUpdate = get_option( 'mainwp_timeDailyUpdate' ); $new_timeDailyUpdate = isset( $_POST['mainwp_timeDailyUpdate'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_timeDailyUpdate'] ) ) : ''; if ( $current_timeDailyUpdate !== $new_timeDailyUpdate ) { MainWP_Utility::update_option( 'mainwp_timeDailyUpdate', $new_timeDailyUpdate ); } $old_freq = (int) get_option( 'mainwp_frequencyDailyUpdate', 2 ); $new_freq = ( isset( $_POST['mainwp_frequencyDailyUpdate'] ) ? intval( $_POST['mainwp_frequencyDailyUpdate'] ) : 2 ); if ( $old_freq !== $new_freq ) { MainWP_Utility::update_option( 'mainwp_frequencyDailyUpdate', $new_freq ); MainWP_Logger::instance()->log_update_check( 'New frequency daily :: ' . $new_freq ); } $curr_frequency_updates = get_option( 'mainwp_frequency_AutoUpdate', 'daily' ); $new_frequency_updates = isset( $_POST['mainwp_frequency_AutoUpdate'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_frequency_AutoUpdate'] ) ) : 'daily'; if ( $new_frequency_updates !== $curr_frequency_updates ) { MainWP_Utility::update_option( 'mainwp_frequency_AutoUpdate', $new_frequency_updates ); } $curr_day_updates = (int) get_option( 'mainwp_dayinweek_AutoUpdate', 0 ); $new_day_updates = isset( $_POST['mainwp_dayinweek_AutoUpdate'] ) ? intval( wp_unslash( $_POST['mainwp_dayinweek_AutoUpdate'] ) ) : 0; if ( $new_day_updates !== $curr_day_updates ) { MainWP_Utility::update_option( 'mainwp_dayinweek_AutoUpdate', $new_day_updates ); } $curr_dayinmonth_updates = (int) get_option( 'mainwp_dayinmonth_AutoUpdate', 1 ); $new_dayinmonth_updates = isset( $_POST['mainwp_dayinmonth_AutoUpdate'] ) ? intval( wp_unslash( $_POST['mainwp_dayinmonth_AutoUpdate'] ) ) : 1; if ( $new_dayinmonth_updates !== $curr_dayinmonth_updates ) { MainWP_Utility::update_option( 'mainwp_dayinmonth_AutoUpdate', $new_dayinmonth_updates ); } $curr_time_updates = get_option( 'mainwp_time_AutoUpdate', '00:00' ); $new_time_updates = isset( $_POST['mainwp_time_AutoUpdate'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_time_AutoUpdate'] ) ) : '00:00'; if ( $new_time_updates !== $curr_time_updates ) { MainWP_Utility::update_option( 'mainwp_time_AutoUpdate', $new_time_updates ); } MainWP_Cron_Jobs_Auto_Updates::set_next_auto_updates_time(); $new_delay = ( isset( $_POST['mainwp_delay_autoupdate'] ) ? intval( $_POST['mainwp_delay_autoupdate'] ) : 1 ); MainWP_Utility::update_option( 'mainwp_delay_autoupdate', $new_delay ); $val = ( isset( $_POST['mainwp_sidebarPosition'] ) ? intval( $_POST['mainwp_sidebarPosition'] ) : 1 ); $user = wp_get_current_user(); if ( $user ) { update_user_option( $user->ID, 'mainwp_sidebarPosition', $val, true ); } MainWP_Utility::update_option( 'mainwp_numberdays_Outdate_Plugin_Theme', ! empty( $_POST['mainwp_numberdays_Outdate_Plugin_Theme'] ) ? intval( $_POST['mainwp_numberdays_Outdate_Plugin_Theme'] ) : 365 ); $actions_notification_enable = ( isset( $_POST['mainwp_site_actions_notification_enable'] ) ? 1 : 0 ); MainWP_Utility::update_option( 'mainwp_site_actions_notification_enable', $actions_notification_enable ); //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized // Handle custom date/time formats. if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] ) && '\c\u\s\t\o\m' === wp_unslash( $_POST['date_format'] ) ) { $_POST['date_format'] = wp_unslash( $_POST['date_format_custom'] ); } if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] ) && '\c\u\s\t\o\m' === wp_unslash( $_POST['time_format'] ) ) { $_POST['time_format'] = wp_unslash( $_POST['time_format_custom'] ); } if ( isset( $_POST['timezone_string'] ) ) { // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', wp_unslash( $_POST['timezone_string'] ) ) ) { $_POST['gmt_offset'] = wp_unslash( $_POST['timezone_string'] ); $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', wp_unslash( $_POST['gmt_offset'] ) ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated $_POST['timezone_string'] = ''; } $options = array( 'gmt_offset', 'date_format', 'time_format', 'timezone_string', ); foreach ( $options as $option ) { $value = null; if ( isset( $_POST[ $option ] ) ) { $value = wp_unslash( $_POST[ $option ] ); if ( ! is_array( $value ) ) { $value = trim( $value ); } } update_option( $option, $value ); } } //phpcs:enable MainWP_Utility::update_option( 'mainwp_use_favicon', 1 ); /** * Action: mainwp_after_save_general_settings * * Fires after save general settings. * * @since 4.1 */ do_action( 'mainwp_after_save_general_settings', $_POST ); $new_settings = self::get_all_settings_values(); /** * Action: mainwp_after_save_settings * * Fires after save settings. * * @since 6.0 * * @param array $new_settings The new settings. * @param array $old_settings The old settings. */ do_action( 'mainwp_after_save_settings', $new_settings, $old_settings ); } return true; } return false; } /** * Method get_all_settings_values(). * * @param mixed $keys_only True if get Keys only. * * @return array All Settings Fields. */ public static function get_all_settings_values( $keys_only = false ) { $keys = array( 'mainwp_hide_update_everything', 'mainwp_pluginAutomaticDailyUpdate', 'mainwp_themeAutomaticDailyUpdate', 'mainwp_transAutomaticDailyUpdate', 'mainwp_automaticDailyUpdate', 'mainwp_show_language_updates', 'mainwp_disable_update_confirmations', 'mainwp_backup_before_upgrade', 'mainwp_backup_before_upgrade_days', 'mainwp_maximumComments', 'mainwp_automatic_update_next_run_timestamp', 'mainwp_delay_autoupdate', 'mainwp_numberdays_Outdate_Plugin_Theme', 'mainwp_check_http_response', 'mainwp_check_http_response_method', 'mainwp_site_actions_notification_enable', 'mainwp_use_favicon', 'mainwp_backupsOnServer', 'mainwp_maximumFileDescriptors', 'mainwp_maximumFileDescriptorsAuto', 'mainwp_backupOnExternalSources', 'mainwp_archiveFormat', 'mainwp_notificationOnBackupFail', 'mainwp_notificationOnBackupStart', 'mainwp_chunkedBackupTasks', 'mainwp_primaryBackup', 'mainwp_enableLegacyBackupFeature', 'mainwp_global_uptime_monitoring_settings', 'mainwp_disableSitesHealthMonitoring', 'mainwp_sitehealthThreshold', 'mainwp_maximumRequests', 'mainwp_minimumDelay', 'mainwp_maximumIPRequests', 'mainwp_minimumIPDelay', 'mainwp_maximumSyncRequests', 'mainwp_maximumInstallUpdateRequests', 'mainwp_sslVerifyCertificate', 'mainwp_connect_signature_algo', 'mainwp_verify_connection_method', 'mainwp_forceUseIPv4', 'mainwp_wp_cron', 'mainwp_warm_cache_pages_ttl', 'mainwp_optimize', 'mainwp_maximum_uptime_monitoring_requests', 'mainwp_chunksitesnumber', 'mainwp_chunksleepinterval', 'mainwp_settings_sync_data', 'mainwp_module_log_settings', 'mainwp_module_log_settings_logs_selection_data', 'mainwp_uptimecheck_running', 'mainwp_uptimecheck_auto_main_counter_lasttime_started', 'mainwp_enable_guided_tours', 'mainwp_enable_guided_chatbase', 'mainwp_enable_guided_video', 'mainwp_enable_cloudways_api', 'mainwp_enable_gridpane_api', 'mainwp_enable_vultr_api', 'mainwp_enable_linode_api', 'mainwp_enable_digitalocean_api', 'mainwp_enable_cpanel_api', 'mainwp_enable_plesk_api', 'mainwp_enable_kinsta_api', ); if ( $keys_only ) { return $keys; } $values = array(); foreach ( $keys as $key ) { $values[ $key ] = get_option( $key ); } return $values; } /** * Render the MainWP Settings Page. * * @uses \MainWP\Dashboard\MainWP_Monitoring_View * @uses \MainWP\Dashboard\MainWP_Manage_Backups::render_settings() * @uses \MainWP\Dashboard\MainWP_Utility::get_http_codes() */ public static function render() { //phpcs:ignore -- NOSONAR - complex method. if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) { \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) ); return; } static::render_header( '' ); ?>

/>
/>
>
>
>
' . esc_html( date_i18n( $timezone_format, false, true ) ) . '' ); ?> ' . esc_html( date_i18n( $timezone_format ) ) . '' ); ?> format( 'I' ); if ( $dst ) { esc_html_e( 'This timezone is currently in daylight saving time.', 'mainwp' ); } else { esc_html_e( 'This timezone is currently in standard time.', 'mainwp' ); } ?> ' . wp_date( esc_html__( 'F j, Y', 'mainwp' ) . ' ' . esc_html__( 'g:i a', 'mainwp' ), esc_html( $transitions[1]['ts'] ) ) . '' ); // phpcs:ignore WordPress.Security.EscapeOutput } else { esc_html_e( 'This timezone does not observe daylight saving time.', 'mainwp' ); } } ?>
' . esc_html( date_i18n( $format ) ) . '' . esc_html( $format ) . "
\n"; } echo '' . '' . '' . '
' . '' . esc_html__( 'Preview:', 'mainwp' ) . ' ' . esc_html( date_i18n( get_option( 'date_format' ) ) ) . '' . "\n" . ''; ?>
' . esc_html( date_i18n( $format ) ) . '' . esc_html( $format ) . "
\n"; } echo '' . '' . '' . '
' . '' . esc_html__( 'Preview:', 'mainwp' ) . ' ' . esc_html( date_i18n( get_option( 'time_format' ) ) ) . '' . "\n" . ''; ?>
get_websites_last_automatic_sync(); $lasttimeAutomatic = get_option( 'mainwp_updatescheck_last_timestamp' ); $lasttimeStartAutomatic = get_option( 'mainwp_updatescheck_start_last_timestamp' ); $local_timestamp = MainWP_Utility::get_timestamp(); if ( empty( $lasttimeStartAutomatic ) && ! empty( $lasttimeAutomatic ) ) { $lasttimeStartAutomatic = $lasttimeAutomatic; } if ( empty( $lastAutomaticUpdate ) ) { $nextAutomaticUpdate = esc_html__( 'Any minute', 'mainwp' ); } elseif ( 0 < MainWP_Auto_Updates_DB::instance()->get_websites_check_updates_count( $lasttimeStartAutomatic ) ) { $nextAutomaticUpdate = esc_html__( 'Processing your websites.', 'mainwp' ); } else { $next_time = MainWP_System_Cron_Jobs::get_next_time_automatic_update_to_show(); if ( $next_time < $local_timestamp + 5 * MINUTE_IN_SECONDS ) { $nextAutomaticUpdate = esc_html__( 'Any minute', 'mainwp' ); } else { $nextAutomaticUpdate = MainWP_Utility::format_timestamp( $next_time ); } } if ( empty( $lastAutomaticUpdate ) ) { $lastAutomaticUpdate = esc_html__( 'Never', 'mainwp' ); } else { $lastAutomaticUpdate = MainWP_Utility::format_timestamp( $lastAutomaticUpdate ); } return array( 'last' => $lastAutomaticUpdate, 'next' => $nextAutomaticUpdate, ); } /** * Returns false or the location of the OpenSSL Lib File. * * @return mixed false|opensslLibLocation * * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_openssl_config_warning() */ public static function show_openssl_lib_config() { return MainWP_Server_Information_Handler::is_openssl_config_warning() ? true : false; } /** * Render Advanced Options Subpage. * * @uses \MainWP\Dashboard\MainWP_Utility::update_option() */ public static function render_advanced() { //phpcs:ignore -- NOSONAR - complex method. if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) { \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) ); return; } if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'SettingsAdvanced' ) ) { $old_settings = static::get_all_settings_values(); /** * Action: mainwp_before_save_advanced_settings * * Fires before save advanced settings. * * @since 4.1 */ do_action( 'mainwp_before_save_advanced_settings', $_POST ); MainWP_Utility::update_option( 'mainwp_maximumRequests', ! empty( $_POST['mainwp_maximumRequests'] ) ? intval( $_POST['mainwp_maximumRequests'] ) : 4 ); MainWP_Utility::update_option( 'mainwp_minimumDelay', ! empty( $_POST['mainwp_minimumDelay'] ) ? intval( $_POST['mainwp_minimumDelay'] ) : 200 ); MainWP_Utility::update_option( 'mainwp_maximumIPRequests', ! empty( $_POST['mainwp_maximumIPRequests'] ) ? intval( $_POST['mainwp_maximumIPRequests'] ) : 1 ); MainWP_Utility::update_option( 'mainwp_minimumIPDelay', ! empty( $_POST['mainwp_minimumIPDelay'] ) ? intval( $_POST['mainwp_minimumIPDelay'] ) : 1000 ); MainWP_Utility::update_option( 'mainwp_maximumSyncRequests', ! empty( $_POST['mainwp_maximumSyncRequests'] ) ? intval( $_POST['mainwp_maximumSyncRequests'] ) : 8 ); MainWP_Utility::update_option( 'mainwp_maximumInstallUpdateRequests', ! empty( $_POST['mainwp_maximumInstallUpdateRequests'] ) ? intval( $_POST['mainwp_maximumInstallUpdateRequests'] ) : 3 ); MainWP_Utility::update_option( 'mainwp_sslVerifyCertificate', isset( $_POST['mainwp_sslVerifyCertificate'] ) ? 1 : 0 ); MainWP_Utility::update_option( 'mainwp_connect_signature_algo', isset( $_POST['mainwp_settings_openssl_alg'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_settings_openssl_alg'] ) ) : 0 ); MainWP_Utility::update_option( 'mainwp_verify_connection_method', isset( $_POST['mainwp_settings_verify_connection_method'] ) ? intval( $_POST['mainwp_settings_verify_connection_method'] ) : 0 ); MainWP_Utility::update_option( 'mainwp_forceUseIPv4', isset( $_POST['mainwp_forceUseIPv4'] ) ? 1 : 0 ); $use_wpcron = ! isset( $_POST['mainwp_options_wp_cron'] ) ? 0 : 1; MainWP_Utility::update_option( 'mainwp_wp_cron', $use_wpcron ); MainWP_Utility::update_option( 'mainwp_warm_cache_pages_ttl', intval( $_POST['mainwp_warm_cache_pages_ttl'] ) ); MainWP_Utility::update_option( 'mainwp_optimize', ( ! isset( $_POST['mainwp_optimize'] ) ? 0 : 1 ) ); MainWP_Utility::update_option( 'mainwp_auto_correct_site_url', ( ! isset( $_POST['mainwp_auto_correct_site_url'] ) ? 0 : 1 ) ); MainWP_Utility::update_option( 'mainwp_maximum_uptime_monitoring_requests', ! empty( $_POST['mainwp_maximumUptimeMonitoringRequests'] ) ? intval( $_POST['mainwp_maximumUptimeMonitoringRequests'] ) : 10 ); MainWP_Utility::update_option( 'mainwp_chunksitesnumber', isset( $_POST['mainwp_chunksitesnumber'] ) ? intval( $_POST['mainwp_chunksitesnumber'] ) : 10 ); MainWP_Utility::update_option( 'mainwp_chunksleepinterval', isset( $_POST['mainwp_chunksleepinterval'] ) ? intval( $_POST['mainwp_chunksleepinterval'] ) : 5 ); $sync_data = array(); if ( isset( $_POST['mainwp_settings_sync_data'] ) && is_array( $_POST['mainwp_settings_sync_data'] ) ) { $selected_data = array_map( 'sanitize_text_field', wp_unslash( $_POST['mainwp_settings_sync_data'] ) ); foreach ( $selected_data as $name ) { $sync_data[ $name ] = 1; } } if ( isset( $_POST['mainwp_settings_sync_name'] ) && is_array( $_POST['mainwp_settings_sync_name'] ) ) { $name_data = array_map( 'sanitize_text_field', wp_unslash( $_POST['mainwp_settings_sync_name'] ) ); foreach ( $name_data as $name ) { if ( ! isset( $sync_data[ $name ] ) ) { $sync_data[ $name ] = 0; } } } MainWP_Utility::update_option( 'mainwp_settings_sync_data', wp_json_encode( $sync_data ) ); // required check. MainWP_Uptime_Monitoring_Schedule::instance()->check_to_disable_schedule_individual_uptime_monitoring(); // required a check to sync the settings. if ( isset( $_POST['mainwp_openssl_lib_location'] ) ) { $openssl_loc = ! empty( $_POST['mainwp_openssl_lib_location'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_openssl_lib_location'] ) ) : ''; MainWP_Utility::update_option( 'mainwp_opensslLibLocation', $openssl_loc ); } /** * Action: mainwp_after_save_advanced_settings * * Fires after advanced settings save. * * @since 4.1 */ do_action( 'mainwp_after_save_advanced_settings', $_POST ); $new_settings = self::get_all_settings_values(); /** * Action: mainwp_after_save_settings * * Fires after save settings. * * @since 6.0 * * @param array $new_settings The new settings. * @param array $old_settings The old settings. */ do_action( 'mainwp_after_save_settings', $new_settings, $old_settings ); } static::render_header( 'Advanced' ); ?>

', ' ' ); ?>

/>
/>
/>
/>
" data-inverted="" data-position="top left">
>
" data-inverted="" data-position="top left">
>
/>
data-inverted="" data-position="top left">
    $title ) { $_selected = ''; if ( ! isset( $sync_data_settings[ $name ] ) || 1 === (int) $sync_data_settings[ $name ] ) { $_selected = 'checked'; } ?>
  • value="">
__( 'WordPress updates information', 'mainwp' ), 'plugin_updates' => __( 'Plugins updates information', 'mainwp' ), 'theme_updates' => __( 'Themes updates information', 'mainwp' ), 'translation_updates' => __( 'Translations updates information', 'mainwp' ), 'recent_comments' => __( 'Recent comments', 'mainwp' ), 'recent_posts' => __( 'Recent posts', 'mainwp' ), 'recent_pages' => __( 'Recent pages', 'mainwp' ), 'securityStats' => __( 'Site hardening information', 'mainwp' ), 'directories' => __( 'Site directory listing (needed for legacy backup feature)', 'mainwp' ), 'categories' => __( 'Posts catetegories', 'mainwp' ), 'totalsize' => __( 'Website size (needed for Clone and legacy backup features)', 'mainwp' ), 'dbsize' => __( 'Database size information', 'mainwp' ), 'plugins' => __( 'Installed plugins', 'mainwp' ), 'themes' => __( 'Installed Themes', 'mainwp' ), 'users' => __( 'Users information', 'mainwp' ), 'plugins_outdate_info' => __( 'Abandoned plugins information', 'mainwp' ), 'themes_outdate_info' => __( 'Abandoned themes information', 'mainwp' ), 'health_site_status' => __( 'Site health information', 'mainwp' ), 'child_site_actions_data' => __( 'Non-MainWP changes data', 'mainwp' ), 'othersData' => __( 'Other data (required by some extensions)', 'mainwp' ), ); } /** * Method get_data_list_to_sync(). * * @return array Data list to sync. */ public function get_data_list_to_sync() { $sync_data_settings = get_option( 'mainwp_settings_sync_data' ); if ( false === $sync_data_settings ) { $default_sync = static::get_data_sync_default(); $sync_lists = array_fill_keys( array_keys( $default_sync ), 1 ); MainWP_Utility::update_option( 'mainwp_settings_sync_data', wp_json_encode( $sync_lists ) ); return $sync_lists; } $sync_lists = ! empty( $sync_data_settings ) ? json_decode( $sync_data_settings, true ) : array(); if ( ! is_array( $sync_lists ) ) { $sync_lists = array(); } return $sync_lists; } /** * Render MainWP Tools SubPage. * * @uses \MainWP\Dashboard\MainWP_UI::render_screen_options() */ public static function render_mainwp_tools() { // phpcs:ignore -- NOSONAR - complex. if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) { \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) ); return; } static::render_header( 'MainWPTools' ); ?>
', ' ' ); ?>
render_select_custom_themes(); ?>

/>
/>
/>
get_current_user_theme(); if ( false === $custom_theme ) { // to compatible with Custom Dashboard extension settings. $compat_settings = get_option( 'mainwp_custom_dashboard_settings' ); if ( is_array( $compat_settings ) && isset( $compat_settings['theme'] ) ) { $compat_theme = $compat_settings['theme']; } if ( null !== $compat_theme ) { $custom_theme = $compat_theme; } } $themes_files = static::get_instance()->get_custom_themes_files(); if ( empty( $themes_files ) ) { $themes_files = array(); } ?>
get_custom_theme_folder(); $scan_dir = $dirs[0]; $handle = opendir( $scan_dir ); $themes = array(); if ( $handle ) { $filename = readdir( $handle ); while ( false !== $filename ) { $correct_file = true; if ( '.' === substr( $filename, 0, 1 ) || 'index.php' === $filename || '.css' !== substr( $filename, - 4 ) ) { $correct_file = false; } if ( $correct_file ) { $theme = basename( $filename, '.css' ); $theme = str_replace( '-theme', '', $theme ); $themes[ $filename ] = trim( $theme ); } $filename = readdir( $handle ); // to while loop. } closedir( $handle ); } return $themes; } /** * Get selected MainWP theme name. */ public function get_selected_theme() { $selected_theme = false; $custom_theme = $this->get_current_user_theme(); if ( false === $custom_theme ) { // to compatible with Custom Dashboard extension settings. $compat_settings = get_option( 'mainwp_custom_dashboard_settings' ); if ( is_array( $compat_settings ) && isset( $compat_settings['theme'] ) ) { $compat_theme = $compat_settings['theme']; } if ( null !== $compat_theme ) { $custom_theme = $compat_theme; } } if ( ! empty( $custom_theme ) ) { if ( 'default' === $custom_theme || 'default-dark' === $custom_theme || 'default-2024' === $custom_theme || 'dark' === $custom_theme || 'wpadmin' === $custom_theme || 'minimalistic' === $custom_theme ) { return $custom_theme; } $dirs = $this->get_custom_theme_folder(); $theme_dir = $dirs[0]; $file = $theme_dir . $custom_theme; if ( file_exists( $file ) && '.css' === substr( $file, - 4 ) ) { $selected_theme = $custom_theme; } } return $selected_theme; } /** * Get custom MainWP theme folder. */ public function get_custom_theme_folder() { $dirs = MainWP_System_Utility::get_mainwp_dir(); global $wp_filesystem; if ( is_array( $dirs ) && ! $wp_filesystem->exists( $dirs[0] . 'themes' ) && $wp_filesystem->exists( $dirs[0] . 'custom-dashboard' ) ) { // re-name the custom-dashboard folder to compatible. $wp_filesystem->move( $dirs[0] . 'custom-dashboard', $dirs[0] . 'themes' ); } return MainWP_System_Utility::get_mainwp_dir_allow_access( 'themes' ); } /** * Get current user's selected theme. */ public function get_current_user_theme() { $custom_theme = get_user_option( 'mainwp_selected_theme' ); if ( empty( $custom_theme ) ) { $custom_theme = get_option( 'mainwp_selected_theme', 'default' ); } return $custom_theme; } /** * Export Child Sites and save as .csv file. * * @uses \MainWP\Dashboard\MainWP_DB::query() * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user() * @uses \MainWP\Dashboard\MainWP_DB::data_seek() * @uses \MainWP\Dashboard\MainWP_DB::fetch_object() * @uses \MainWP\Dashboard\MainWP_Utility::map_site() */ public static function export_sites() { if ( isset( $_GET['doExportSites'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'export_sites' ) ) { $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( true ); $websites = MainWP_DB::instance()->query( $sql ); if ( ! $websites ) { die( 'Not found sites' ); } $keys = array( 'name', 'url', 'adminname', 'adminpasswd', 'wpgroups', 'uniqueId', 'http_user', 'http_pass', 'verify_certificate', 'ssl_version' ); $allowedHeaders = array( 'site name', 'url', 'admin name', 'admin password', 'tag', 'security id', 'http username', 'http password', 'verify certificate', 'ssl version' ); $csv = "#\r"; $csv .= '# Your password is never stored by your Dashboard and never sent to MainWP.com. Once this initial connection is complete, your MainWP Dashboard generates a secure Public and Private key pair (2048 bits) using OpenSSL, allowing future connections without needing your password again. For added security, you can even change this admin password once connected, just be sure not to delete the admin account, as this would disrupt the connection.' . "\r"; $csv .= "#\r"; $csv .= implode( ',', $allowedHeaders ) . "\r"; MainWP_DB::data_seek( $websites, 0 ); while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { if ( empty( $website ) ) { continue; } $row = MainWP_Utility::map_site( $website, $keys, false ); // MWP-1548: decrypt http_user / http_pass before they hit // the CSV. The export file is meant for cross-install // transfer (admin re-imports on another dashboard); a // file_key envelope from this install would be unreadable // there. Plaintext on disk preserves today's portability // contract -- the export was already plaintext pre-fix, // and this hop neither widens nor narrows that exposure. if ( isset( $row['http_user'] ) ) { $row['http_user'] = MainWP_Credential_Storage::decrypt_credential( $row['http_user'] ); } if ( isset( $row['http_pass'] ) ) { $row['http_pass'] = MainWP_Credential_Storage::decrypt_credential( $row['http_pass'] ); } $row = array_map( static function ( $value ) { return str_replace( '"', '""', (string) $value ); }, $row ); $csv .= '"' . implode( '","', $row ) . '"' . "\r"; } header( 'Content-Type: text/csv; charset=utf-8' ); header( 'Content-Disposition: attachment; filename=export-sites.csv' ); echo $csv; // phpcs:ignore WordPress.Security.EscapeOutput exit(); } } /** * Render MainWP Email Settings SubPage. * * @uses \MainWP\Dashboard\MainWP_Notification_Settings::get_notification_types() * @uses \MainWP\Dashboard\MainWP_Notification_Settings::render_edit_settings() * @uses \MainWP\Dashboard\MainWP_Notification_Settings::emails_general_settings_handle() * @uses \MainWP\Dashboard\MainWP_Notification_Settings::render_all_settings() * @uses \MainWP\Dashboard\MainWP_Notification_Template::handle_template_file_action() */ public static function render_email_settings() { $notification_emails = MainWP_Notification_Settings::get_notification_types(); static::render_header( 'Emails' ); $edit_email = isset( $_GET['edit-email'] ) ? sanitize_text_field( wp_unslash( $_GET['edit-email'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized if ( ! empty( $edit_email ) && isset( $notification_emails[ $edit_email ] ) ) { $updated_templ = MainWP_Notification_Template::instance()->handle_template_file_action(); MainWP_Notification_Settings::instance()->render_edit_settings( $edit_email, $updated_templ ); } else { $updated = MainWP_Notification_Settings::emails_general_settings_handle(); MainWP_Notification_Settings::instance()->render_all_settings( $updated ); } static::render_footer( 'Emails' ); } /** * Method mainwp_help_content() * * Creates the MainWP Help Documentation List for the help component in the sidebar. */ public static function mainwp_help_content() { if ( isset( $_GET['page'] ) && ( 'Settings' === $_GET['page'] || 'SettingsAdvanced' === $_GET['page'] || 'MainWPTools' === $_GET['page'] || 'MonitoringSettings' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>

Your custom text * * @since 5.2 */ do_action( 'mainwp_settings_help_item' ); } } /** * Method render_monitoring() * * Render Monitoring Settings. * * @uses \MainWP\Dashboard\MainWP_Monitoring_View::render_settings() */ public static function render_monitoring() { if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) { \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) ); return; } static::render_header( 'Monitoring' ); ?>