PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / trunk
MainWP Dashboard: Self-hosted WordPress Management for Agencies vtrunk
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 5.2.2 5.3 All 153 releases
mainwp / class / class-mainwp-system-view.php

class-mainwp-system-view.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies trunk, at class/class-mainwp-system-view.php

1,454 lines 90.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP System View.
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Class MainWP_System_View
17 *
18 * @package MainWP\Dashboard
19 */
20 class MainWP_System_View { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
21
22 /**
23 * Get Class Name
24 *
25 * @return string __CLASS__
26 */
27 public static function get_class_name() {
28 return __CLASS__;
29 }
30
31 /**
32 * Method get_mainwp_translations()
33 * Build Translations Array.
34 *
35 * @return array $mainwpTranslations.
36 */
37 public static function get_mainwp_translations() { // phpcs:ignore -- NOSONAR - complex.
38
39 /**
40 * Method mainwp_add_translation()
41 *
42 * Grab info needed to build the translation array.
43 *
44 * @param mixed $pArray Array of tranlatable text.
45 * @param mixed $pKey Key for each array enty.
46 * @param mixed $pText Text for each array entry.
47 */
48 function mainwp_add_translation( &$pArray, $pKey, $pText ) {
49 if ( ! is_array( $pArray ) ) {
50 $pArray = array();
51 }
52
53 // Keep this normalization aligned with MainWP.I18n.t() in assets/js/mainwp.js.
54 $strippedText = preg_replace( '/[^\p{L}\p{N}_]/u', '_', $pKey );
55
56 $pArray[ $strippedText ] = $pText;
57 }
58
59 $mainwpTranslations = array();
60 mainwp_add_translation( $mainwpTranslations, 'Update settings.', esc_html__( 'Update settings.', 'mainwp' ) );
61 mainwp_add_translation( $mainwpTranslations, 'Settings have been updated.', esc_html__( 'Settings have been updated.', 'mainwp' ) );
62 mainwp_add_translation( $mainwpTranslations, 'An error occurred.', esc_html__( 'An error occurred.', 'mainwp' ) );
63 mainwp_add_translation( $mainwpTranslations, 'Testing login.', esc_html__( 'Testing login.', 'mainwp' ) );
64 mainwp_add_translation( $mainwpTranslations, 'Your login is valid.', esc_html__( 'Your login is valid.', 'mainwp' ) );
65 mainwp_add_translation( $mainwpTranslations, 'Your login is invalid.', esc_html__( 'Your login is invalid.', 'mainwp' ) );
66 mainwp_add_translation( $mainwpTranslations, 'An error occurred, please contact us.', esc_html__( 'An error occurred, please contact us.', 'mainwp' ) );
67 mainwp_add_translation( $mainwpTranslations, 'more', esc_html__( 'more', 'mainwp' ) );
68 mainwp_add_translation( $mainwpTranslations, 'less', esc_html__( 'less', 'mainwp' ) );
69 mainwp_add_translation( $mainwpTranslations, 'An error occurred: ', esc_html__( 'An error occurred: ', 'mainwp' ) );
70 mainwp_add_translation( $mainwpTranslations, 'No data available. Connect your sites using the Settings submenu.', esc_html__( 'No data available. Connect your sites using the Settings submenu.', 'mainwp' ) );
71 mainwp_add_translation( $mainwpTranslations, 'Undefined error.', esc_html__( 'Undefined error.', 'mainwp' ) );
72 mainwp_add_translation( $mainwpTranslations, 'PENDING', esc_html__( 'PENDING', 'mainwp' ) );
73 mainwp_add_translation( $mainwpTranslations, 'UPDATING', esc_html__( 'UPDATING', 'mainwp' ) );
74 mainwp_add_translation( $mainwpTranslations, 'UPGRADING', esc_html__( 'UPGRADING', 'mainwp' ) );
75 mainwp_add_translation( $mainwpTranslations, 'FAILED', esc_html__( 'FAILED', 'mainwp' ) );
76 mainwp_add_translation( $mainwpTranslations, 'DONE', esc_html__( 'DONE', 'mainwp' ) );
77 mainwp_add_translation( $mainwpTranslations, 'SYNCING', esc_html__( 'SYNCING', 'mainwp' ) );
78 mainwp_add_translation( $mainwpTranslations, 'DISCONNECTED', esc_html__( 'DISCONNECTED', 'mainwp' ) );
79 mainwp_add_translation( $mainwpTranslations, 'TIMEOUT', esc_html__( 'TIMEOUT', 'mainwp' ) );
80 mainwp_add_translation( $mainwpTranslations, 'Ignored', esc_html__( 'Ignored', 'mainwp' ) );
81 /* translators: %1s: Item type (e.g. plugins, themes) */
82 mainwp_add_translation( $mainwpTranslations, 'No ignored %1s', esc_html__( 'No ignored %1s', 'mainwp' ) );
83 mainwp_add_translation( $mainwpTranslations, 'No ignored %1 conflicts', esc_html__( 'No ignored %1 conflicts', 'mainwp' ) );
84 mainwp_add_translation( $mainwpTranslations, 'No ignored plugins', esc_html__( 'No ignored plugins', 'mainwp' ) );
85 mainwp_add_translation( $mainwpTranslations, 'No ignored themes', esc_html__( 'No ignored themes', 'mainwp' ) );
86 mainwp_add_translation( $mainwpTranslations, 'Upgrading..', esc_html__( 'Upgrading..', 'mainwp' ) );
87 mainwp_add_translation( $mainwpTranslations, 'Update successful', esc_html__( 'Update successful', 'mainwp' ) );
88 mainwp_add_translation( $mainwpTranslations, 'Update failed', esc_html__( 'Update failed', 'mainwp' ) );
89 mainwp_add_translation( $mainwpTranslations, 'Show All', esc_html__( 'Show All', 'mainwp' ) );
90 mainwp_add_translation( $mainwpTranslations, 'Show', esc_html__( 'Show', 'mainwp' ) );
91 mainwp_add_translation( $mainwpTranslations, 'Hide All', esc_html__( 'Hide All', 'mainwp' ) );
92 mainwp_add_translation( $mainwpTranslations, 'Hide', esc_html__( 'Hide', 'mainwp' ) );
93 mainwp_add_translation( $mainwpTranslations, 'Testing ...', esc_html__( 'Testing ...', 'mainwp' ) );
94 mainwp_add_translation( $mainwpTranslations, 'Test Settings', esc_html__( 'Test Settings', 'mainwp' ) );
95 mainwp_add_translation( $mainwpTranslations, 'Received wrong response from the server.', esc_html__( 'Received wrong response from the server.', 'mainwp' ) );
96 mainwp_add_translation( $mainwpTranslations, 'Untitled', esc_html__( 'Untitled', 'mainwp' ) );
97 mainwp_add_translation( $mainwpTranslations, 'Are you sure you want to remove this destination. This could make some of the backup tasks invalid.', esc_html__( 'Are you sure you want to remove this destination. This could make some of the backup tasks invalid.', 'mainwp' ) );
98 mainwp_add_translation( $mainwpTranslations, 'Starting backup task.', esc_html__( 'Starting backup task.', 'mainwp' ) );
99 mainwp_add_translation( $mainwpTranslations, 'Cancel', esc_html__( 'Cancel', 'mainwp' ) );
100 mainwp_add_translation( $mainwpTranslations, 'Backup task complete', esc_html__( 'Backup task complete', 'mainwp' ) );
101 mainwp_add_translation( $mainwpTranslations, 'with errors', esc_html__( 'with errors', 'mainwp' ) );
102 mainwp_add_translation( $mainwpTranslations, 'Close', esc_html__( 'Close', 'mainwp' ) );
103 mainwp_add_translation( $mainwpTranslations, 'Creating backupfile.', esc_html__( 'Creating backupfile.', 'mainwp' ) );
104 mainwp_add_translation( $mainwpTranslations, 'Backupfile created successfully.', esc_html__( 'Backupfile created successfully.', 'mainwp' ) );
105 mainwp_add_translation( $mainwpTranslations, 'Download from child site completed.', esc_html__( 'Download from child site completed.', 'mainwp' ) );
106 mainwp_add_translation( $mainwpTranslations, 'Uploading to remote destinations..', esc_html__( 'Uploading to remote destinations..', 'mainwp' ) );
107 mainwp_add_translation( $mainwpTranslations, 'Backup complete.', esc_html__( 'Backup complete.', 'mainwp' ) );
108 mainwp_add_translation( $mainwpTranslations, 'Upload to %1 (%2) failed:', esc_html__( 'Upload to %1 (%2) failed:', 'mainwp' ) );
109 mainwp_add_translation( $mainwpTranslations, 'Upload to %1 (%2) succesful', esc_html__( 'Upload to %1 (%2) succesful', 'mainwp' ) );
110 mainwp_add_translation( $mainwpTranslations, 'Please select websites or tags to add a backup task.', esc_html__( 'Please select websites or tags to add a backup task.', 'mainwp' ) );
111 mainwp_add_translation( $mainwpTranslations, 'Adding the task to MainWP', esc_html__( 'Adding the task to MainWP', 'mainwp' ) );
112 mainwp_add_translation( $mainwpTranslations, 'Please select websites or tags.', esc_html__( 'Please select websites or tags.', 'mainwp' ) );
113 mainwp_add_translation( $mainwpTranslations, 'Are you sure you want to delete this backup task?', esc_html__( 'Are you sure you want to delete this backup task?', 'mainwp' ) );
114 mainwp_add_translation( $mainwpTranslations, 'Removing the task..', esc_html__( 'Removing the task..', 'mainwp' ) );
115 mainwp_add_translation( $mainwpTranslations, 'The task has been removed', esc_html__( 'The task has been removed', 'mainwp' ) );
116 mainwp_add_translation( $mainwpTranslations, 'An unspecified error occurred', esc_html__( 'An unspecified error occurred', 'mainwp' ) );
117 mainwp_add_translation( $mainwpTranslations, 'Connection test failed.', esc_html__( 'Connection test failed.', 'mainwp' ) );
118 mainwp_add_translation( $mainwpTranslations, 'Error message:', esc_html__( 'Error message:', 'mainwp' ) );
119 mainwp_add_translation( $mainwpTranslations, 'Received HTTP-code:', esc_html__( 'Received HTTP-code:', 'mainwp' ) );
120 mainwp_add_translation( $mainwpTranslations, 'Connection test successful.', esc_html__( 'Connection test successful.', 'mainwp' ) );
121 mainwp_add_translation( $mainwpTranslations, 'Invalid response from the server, please try again.', esc_html__( 'Invalid response from the server, please try again.', 'mainwp' ) );
122 mainwp_add_translation( $mainwpTranslations, 'Please enter csv file for upload.', esc_html__( 'Please enter csv file for upload.', 'mainwp' ) );
123 mainwp_add_translation( $mainwpTranslations, 'Please enter a name for the website', esc_html__( 'Please enter a name for the website', 'mainwp' ) );
124 mainwp_add_translation( $mainwpTranslations, 'Please enter a valid URL for your site', esc_html__( 'Please enter a valid URL for your site', 'mainwp' ) );
125 mainwp_add_translation( $mainwpTranslations, 'Please enter a username for the administrator', esc_html__( 'Please enter a username for the administrator', 'mainwp' ) );
126 mainwp_add_translation( $mainwpTranslations, 'Adding the site to MainWP', esc_html__( 'Adding the site to MainWP', 'mainwp' ) );
127 mainwp_add_translation( $mainwpTranslations, 'No MainWP Child plugin detected, first install and activate the plugin and add your site to MainWP afterwards. Click <a href="%1" target="_blank">here</a> to install <a href="%2" target="_blank">MainWP</a> plugin (do not forget to activate it after installation).', esc_html__( 'No MainWP Child plugin detected, first install and activate the plugin and add your site to MainWP afterwards. Click <a href="%1" target="_blank">here</a> to install <a href="%2" target="_blank">MainWP</a> <i class="external alternate icon"></i> plugin (do not forget to activate it after installation).', 'mainwp' ) );
128 mainwp_add_translation( $mainwpTranslations, 'Testing the connection', esc_html__( 'Testing the connection', 'mainwp' ) );
129 mainwp_add_translation( $mainwpTranslations, 'Are you sure you want to delete this site?', esc_html__( 'Are you sure you want to delete this site?', 'mainwp' ) );
130 mainwp_add_translation( $mainwpTranslations, 'Removing and deactivating the MainWP Child plugin..', esc_html__( 'Removing and deactivating the MainWP Child plugin..', 'mainwp' ) );
131 mainwp_add_translation( $mainwpTranslations, 'The site has been removed and the MainWP Child plugin has been disabled.', esc_html__( 'The site has been removed and the MainWP Child plugin has been disabled.', 'mainwp' ) );
132 mainwp_add_translation( $mainwpTranslations, 'The requested site has not been found', esc_html__( 'The requested site has not been found', 'mainwp' ) );
133 mainwp_add_translation( $mainwpTranslations, 'The site has been removed but the MainWP Child plugin could not be disabled', esc_html__( 'The site has been removed but the MainWP Child plugin could not be disabled', 'mainwp' ) );
134 mainwp_add_translation( $mainwpTranslations, 'Removing the site. Please wait...', esc_html__( 'Removing the site. Please wait...', 'mainwp' ) );
135 mainwp_add_translation( $mainwpTranslations, 'Site could not be removed. Please reload the page and try again.', esc_html__( 'Site could not be removed. Please reload the page and try again.', 'mainwp' ) );
136 mainwp_add_translation( $mainwpTranslations, 'Details:', esc_html__( 'Details:', 'mainwp' ) );
137 mainwp_add_translation( $mainwpTranslations, 'The site has been removed. Please make sure that the MainWP Child plugin has been deactivated properly. You will be redirected to the Sites page right away.', esc_html__( 'The site has been removed. Please make sure that the MainWP Child plugin has been deactivated properly. You will be redirected to the Sites page right away.', 'mainwp' ) );
138 mainwp_add_translation( $mainwpTranslations, 'The site has been removed and the MainWP Child plugin has been disabled. You will be redirected to the Sites page right away.', esc_html__( 'The site has been removed and the MainWP Child plugin has been disabled. You will be redirected to the Sites page right away.', 'mainwp' ) );
139 mainwp_add_translation( $mainwpTranslations, 'The site has been removed. You will be redirected to the Sites page right away.', esc_html__( 'The site has been removed. You will be redirected to the Sites page right away.', 'mainwp' ) );
140 mainwp_add_translation( $mainwpTranslations, 'The request timed out. Please make sure that the MainWP Child plugin has been deactivated properly.', esc_html__( 'The request timed out. Please make sure that the MainWP Child plugin has been deactivated properly.', 'mainwp' ) );
141 mainwp_add_translation( $mainwpTranslations, 'An unexpected error occurred. Please reload the page and try again.', esc_html__( 'An unexpected error occurred. Please reload the page and try again.', 'mainwp' ) );
142 mainwp_add_translation( $mainwpTranslations, 'Paused import by user.', esc_html__( 'Paused import by user.', 'mainwp' ) );
143 mainwp_add_translation( $mainwpTranslations, 'Continue', esc_html__( 'Continue', 'mainwp' ) );
144 mainwp_add_translation( $mainwpTranslations, 'Continue import.', esc_html__( 'Continue import.', 'mainwp' ) );
145 mainwp_add_translation( $mainwpTranslations, 'Pause', esc_html__( 'Pause', 'mainwp' ) );
146 mainwp_add_translation( $mainwpTranslations, 'Finished', esc_html__( 'Finished', 'mainwp' ) );
147 mainwp_add_translation( $mainwpTranslations, 'Please enter the Site name.', esc_html__( 'Please enter the Site name.', 'mainwp' ) );
148 mainwp_add_translation( $mainwpTranslations, 'Please enter the Site url.', esc_html__( 'Please enter the Site url.', 'mainwp' ) );
149 mainwp_add_translation( $mainwpTranslations, 'Please enter Admin name of the site.', esc_html__( 'Please enter Admin name of the site.', 'mainwp' ) );
150 mainwp_add_translation( $mainwpTranslations, 'Number of sites to Import: %1 Created sites: %2 Failed: %3', esc_html__( 'Number of sites to Import: %1 Created sites: %2 Failed: %3', 'mainwp' ) );
151 mainwp_add_translation( $mainwpTranslations, 'HTTP error - website does not exist', esc_html__( 'HTTP error - website does not exist', 'mainwp' ) );
152 mainwp_add_translation( $mainwpTranslations, 'No selected Categories', esc_html__( 'No selected Categories', 'mainwp' ) );
153 mainwp_add_translation( $mainwpTranslations, 'Please select websites or tags to add a user.', esc_html__( 'Please select websites or tags to add a user.', 'mainwp' ) );
154 mainwp_add_translation( $mainwpTranslations, 'Number of Users to Import: %1 Created users: %2 Failed: %3', esc_html__( 'Number of Users to Import: %1 Created users: %2 Failed: %3', 'mainwp' ) );
155 mainwp_add_translation( $mainwpTranslations, 'Please enter the username.', esc_html__( 'Please enter the username.', 'mainwp' ) );
156 mainwp_add_translation( $mainwpTranslations, 'Please enter the email.', esc_html__( 'Please enter the email.', 'mainwp' ) );
157 mainwp_add_translation( $mainwpTranslations, 'Please enter the password.', esc_html__( 'Please enter the password.', 'mainwp' ) );
158 mainwp_add_translation( $mainwpTranslations, 'Please select a valid role.', esc_html__( 'Please select a valid role.', 'mainwp' ) );
159 mainwp_add_translation( $mainwpTranslations, 'Loading previous page..', esc_html__( 'Loading previous page..', 'mainwp' ) );
160 mainwp_add_translation( $mainwpTranslations, 'Loading next page..', esc_html__( 'Loading next page..', 'mainwp' ) );
161 mainwp_add_translation( $mainwpTranslations, 'Searching the WordPress repository..', esc_html__( 'Searching the WordPress repository..', 'mainwp' ) );
162 mainwp_add_translation( $mainwpTranslations, 'Please select websites or tags on the right side to install files.', esc_html__( 'Please select websites or tags on the right side to install files.', 'mainwp' ) );
163 mainwp_add_translation( $mainwpTranslations, 'Queued', esc_html__( 'Queued', 'mainwp' ) );
164 mainwp_add_translation( $mainwpTranslations, 'In progress', esc_html__( 'In progress', 'mainwp' ) );
165 mainwp_add_translation( $mainwpTranslations, 'Preparing %1 installation.', esc_html__( 'Preparing %1 installation.', 'mainwp' ) );
166 mainwp_add_translation( $mainwpTranslations, 'Installation successful', esc_html__( 'Installation successful', 'mainwp' ) );
167 mainwp_add_translation( $mainwpTranslations, 'Installation failed', esc_html__( 'Installation failed', 'mainwp' ) );
168 mainwp_add_translation( $mainwpTranslations, 'Please select websites or tags to install files.', esc_html__( 'Please select websites or tags to install files.', 'mainwp' ) );
169 mainwp_add_translation( $mainwpTranslations, 'Creating the backupfile on the child installation, this might take a while depending on the size. Please be patient.', esc_html__( 'Creating the backupfile on the child installation, this might take a while depending on the size. Please be patient.', 'mainwp' ) );
170 mainwp_add_translation( $mainwpTranslations, 'Backupfile on child site created successfully.', esc_html__( 'Backupfile on child site created successfully.', 'mainwp' ) );
171 mainwp_add_translation( $mainwpTranslations, 'Downloading the file.', esc_html__( 'Downloading the file.', 'mainwp' ) );
172 mainwp_add_translation( $mainwpTranslations, 'Download from child completed.', esc_html__( 'Download from child completed.', 'mainwp' ) );
173 mainwp_add_translation( $mainwpTranslations, 'Please wait while we are saving your note', esc_html__( 'Please wait while we are saving your note', 'mainwp' ) );
174 mainwp_add_translation( $mainwpTranslations, 'Note saved.', esc_html__( 'Note saved.', 'mainwp' ) );
175 mainwp_add_translation( $mainwpTranslations, 'An error occurred while saving your message.', esc_html__( 'An error occurred while saving your message.', 'mainwp' ) );
176 mainwp_add_translation( $mainwpTranslations, 'Please search and select users for update password.', esc_html__( 'Please search and select users for update password.', 'mainwp' ) );
177 mainwp_add_translation( $mainwpTranslations, 'All', esc_html__( 'All', 'mainwp' ) );
178 mainwp_add_translation( $mainwpTranslations, 'Any', esc_html__( 'Any', 'mainwp' ) );
179 mainwp_add_translation( $mainwpTranslations, 'HTTP error', esc_html__( 'HTTP error', 'mainwp' ) );
180 mainwp_add_translation( $mainwpTranslations, 'Error on your child WordPress', esc_html__( 'Error on your child WordPress', 'mainwp' ) );
181 mainwp_add_translation( $mainwpTranslations, 'MainWP Child plugin not detected. First, install and activate the plugin and add your site to MainWP afterwards. If you continue experiencing this issue, Please review MainWP Knowledgebase, and if you still have issues, please let us know in the MainWP Community.', esc_html__( 'MainWP Child plugin not detected. First, install and activate the plugin and add your site to MainWP afterwards. If you continue experiencing this issue, Please review MainWP Knowledgebase, and if you still have issues, please let us know in the MainWP Community.', 'mainwp' ) );
182 mainwp_add_translation( $mainwpTranslations, 'Remove', esc_html__( 'Remove', 'mainwp' ) );
183 mainwp_add_translation( $mainwpTranslations, 'Please reconnect to Dropbox', esc_html__( 'Please reconnect to Dropbox', 'mainwp' ) );
184 mainwp_add_translation( $mainwpTranslations, 'Please wait', esc_html__( 'Please wait', 'mainwp' ) );
185 mainwp_add_translation( $mainwpTranslations, 'Upgrading all', esc_html__( 'Upgrading all', 'mainwp' ) );
186 mainwp_add_translation( $mainwpTranslations, 'Upgrading %1', esc_html__( 'Upgrading %1', 'mainwp' ) );
187 mainwp_add_translation( $mainwpTranslations, 'Updating your plan...', esc_html__( 'Updating your plan...', 'mainwp' ) );
188 mainwp_add_translation( $mainwpTranslations, 'Updated your plan', esc_html__( 'Updated your plan', 'mainwp' ) );
189 $mainwp_backup_before_upgrade_days = get_option( 'mainwp_backup_before_upgrade_days' );
190 if ( empty( $mainwp_backup_before_upgrade_days ) || ! ctype_digit( $mainwp_backup_before_upgrade_days ) ) {
191 $mainwp_backup_before_upgrade_days = 7;
192 }
193 mainwp_add_translation( $mainwpTranslations, 'A full backup has not been taken in the last days for the following sites:', str_replace( '%1', '' . $mainwp_backup_before_upgrade_days, esc_html__( 'A full backup has not been taken in the last %1 days for the following sites:', 'mainwp' ) ) );
194 mainwp_add_translation( $mainwpTranslations, 'Starting required backup(s).', esc_html__( 'Starting required backup(s).', 'mainwp' ) );
195 mainwp_add_translation( $mainwpTranslations, 'Required backup(s) complete', esc_html__( 'Required backup(s) complete', 'mainwp' ) );
196 mainwp_add_translation( $mainwpTranslations, 'Continue update anyway', esc_html__( 'Continue update anyway', 'mainwp' ) );
197 mainwp_add_translation( $mainwpTranslations, 'Continue update', esc_html__( 'Continue update', 'mainwp' ) );
198 mainwp_add_translation( $mainwpTranslations, 'Pause', esc_html__( 'Pause', 'mainwp' ) );
199 mainwp_add_translation( $mainwpTranslations, 'Resume', esc_html__( 'Resume', 'mainwp' ) );
200 mainwp_add_translation( $mainwpTranslations, 'Checking if a backup is required for the selected updates...', esc_html__( 'Checking if a backup is required for the selected updates...', 'mainwp' ) );
201 mainwp_add_translation( $mainwpTranslations, 'Full backup required', esc_html__( 'Full backup required', 'mainwp' ) );
202 mainwp_add_translation( $mainwpTranslations, 'Checking backup settings', esc_html__( 'Checking backup settings', 'mainwp' ) );
203 mainwp_add_translation( $mainwpTranslations, 'Hide Shortcuts', esc_html__( 'Hide Shortcuts', 'mainwp' ) );
204 mainwp_add_translation( $mainwpTranslations, 'Show Shortcuts', esc_html__( 'Show Shortcuts', 'mainwp' ) );
205 mainwp_add_translation( $mainwpTranslations, 'Are you sure?', esc_html__( 'Are you sure?', 'mainwp' ) );
206 mainwp_add_translation( $mainwpTranslations, 'Bulk reconnect finished.', esc_html__( 'Bulk reconnect finished.', 'mainwp' ) );
207 mainwp_add_translation( $mainwpTranslations, 'Note Saved', esc_html__( 'Note Saved', 'mainwp' ) );
208 mainwp_add_translation( $mainwpTranslations, 'An error occurred while saving your message', esc_html__( 'An error occurred while saving your message', 'mainwp' ) );
209 mainwp_add_translation( $mainwpTranslations, 'Download from child site completed.', esc_html__( 'Download from child site completed.', 'mainwp' ) );
210 mainwp_add_translation( $mainwpTranslations, 'Please wait while we are saving your note', esc_html__( 'Please wait while we are saving your note', 'mainwp' ) );
211 mainwp_add_translation( $mainwpTranslations, 'Installation Successful', esc_html__( 'Installation Successful', 'mainwp' ) );
212 mainwp_add_translation( $mainwpTranslations, 'Upload to %1 (%2) successful.', esc_html__( 'Upload to %1 (%2) successful.', 'mainwp' ) );
213 mainwp_add_translation( $mainwpTranslations, 'Upload to %1 (%2) failed:', esc_html__( 'Upload to %1 (%2) failed:', 'mainwp' ) );
214 mainwp_add_translation( $mainwpTranslations, 'Updating Themes', esc_html__( 'Updating Themes', 'mainwp' ) );
215 mainwp_add_translation( $mainwpTranslations, 'Updating Plugins', esc_html__( 'Updating Plugins', 'mainwp' ) );
216 mainwp_add_translation( $mainwpTranslations, 'Updating WordPress', esc_html__( 'Updating WordPress', 'mainwp' ) );
217 mainwp_add_translation( $mainwpTranslations, 'updated', esc_html__( 'updated', 'mainwp' ) );
218 mainwp_add_translation( $mainwpTranslations, 'Updating', esc_html__( 'Updating', 'mainwp' ) );
219 mainwp_add_translation( $mainwpTranslations, 'Please enter a valid name for your backup task', esc_html__( 'Please enter a valid name for your backup task', 'mainwp' ) );
220 mainwp_add_translation( $mainwpTranslations, 'The backup task was added successfully', esc_html__( 'The backup task was added successfully', 'mainwp' ) );
221 mainwp_add_translation( $mainwpTranslations, 'Bulk test connection finished', esc_html__( 'Bulk test connection finished', 'mainwp' ) );
222 /* translators: %1: Opening anchor tag, %2: Closing anchor tag, %3: HTTP status code number */
223 mainwp_add_translation( $mainwpTranslations, 'To find out more about what your HTTP status code means please %1click here%2 to locate your number (%3)', esc_html__( 'To find out more about what your HTTP status code means please %1click here%2 to locate your number (%3)', 'mainwp' ) );
224 /* translators: %1: Opening anchor tag, %2: Closing anchor tag */
225 mainwp_add_translation( $mainwpTranslations, 'Refreshing the page for Step 3 "Grab API Keys" in 5 seconds... if refresh fails please %1click here%2.', esc_html__( 'Refreshing the page for Step 3 "Grab API Keys" in 5 seconds... if refresh fails please %1click here%2.', 'mainwp' ) );
226 mainwp_add_translation( $mainwpTranslations, 'No ignored abandoned plugins', esc_html__( 'No ignored abandoned plugins', 'mainwp' ) );
227 mainwp_add_translation( $mainwpTranslations, 'Please upload plugins to install.', esc_html__( 'Please upload plugins to install.', 'mainwp' ) );
228 mainwp_add_translation( $mainwpTranslations, 'Please upload themes to install.', esc_html__( 'Please upload themes to install.', 'mainwp' ) );
229 mainwp_add_translation( $mainwpTranslations, 'Did you know with the %1 you can control the settings of this plugin directly from your MainWP Dashboard?', esc_html__( 'Did you know with the %1 you can control the settings of this plugin directly from your MainWP Dashboard?', 'mainwp' ) );
230 mainwp_add_translation( $mainwpTranslations, 'Did you know with the %1 you can control the settings of these plugins directly from your MainWP Dashboard?', esc_html__( 'Did you know with the %1 you can control the settings of these plugins directly from your MainWP Dashboard?', 'mainwp' ) );
231 mainwp_add_translation( $mainwpTranslations, 'Did you know with the %1 you can control the settings of this theme directly from your MainWP Dashboard?', esc_html__( 'Did you know with the %1 you can control the settings of this theme directly from your MainWP Dashboard?', 'mainwp' ) );
232 mainwp_add_translation( $mainwpTranslations, 'Did you know with the %1 you can control the settings of these themes directly from your MainWP Dashboard?', esc_html__( 'Did you know with the %1 you can control the settings of these themes directly from your MainWP Dashboard?', 'mainwp' ) );
233 mainwp_add_translation( $mainwpTranslations, 'Would you like to use the Bulk Settings Manager with this plugin? Check out the %1Documentation%2.', esc_html__( 'Would you like to use the Bulk Settings Manager with this plugin? Check out the %1Documentation%2.', 'mainwp' ) );
234 mainwp_add_translation( $mainwpTranslations, 'Would you like to use the Bulk Settings Manager with these plugin? Check out the %1Documentation%2.', esc_html__( 'Would you like to use the Bulk Settings Manager with these plugin? Check out the %1Documentation%2.', 'mainwp' ) );
235 mainwp_add_translation( $mainwpTranslations, 'Would you like to use the Bulk Settings Manager with this theme? Check out the %1Documentation%2.', esc_html__( 'Would you like to use the Bulk Settings Manager with this theme? Check out the %1Documentation%2.', 'mainwp' ) );
236 mainwp_add_translation( $mainwpTranslations, 'Would you like to use the Bulk Settings Manager with these themes? Check out the %1Documentation%2.', esc_html__( 'Would you like to use the Bulk Settings Manager with these themes? Check out the %1Documentation%2.', 'mainwp' ) );
237 mainwp_add_translation( $mainwpTranslations, 'is_activated_parent', esc_html__( '%1 could not be deleted. This theme is parent theme for the currently active theme.', 'mainwp' ) );
238 mainwp_add_translation( $mainwpTranslations, 'is_activated_theme', esc_html__( '%1 could not be deleted. This theme is active theme.', 'mainwp' ) );
239 mainwp_add_translation( $mainwpTranslations, 'Change score changed. Click to review changes.', esc_html__( 'Change score changed. Click to review changes.', 'mainwp' ) );
240 mainwp_add_translation( $mainwpTranslations, 'No sites to import', esc_html__( 'No sites to import', 'mainwp' ) );
241 mainwp_add_translation( $mainwpTranslations, 'No valid data rows were found in the import file.', esc_html__( 'No valid data rows were found in the import file.', 'mainwp' ) );
242 mainwp_add_translation( $mainwpTranslations, 'Congratulations!', esc_html__( 'Congratulations!', 'mainwp' ) );
243 mainwp_add_translation( $mainwpTranslations, 'sites imported successfully.', esc_html__( 'sites imported successfully.', 'mainwp' ) );
244
245 return $mainwpTranslations;
246 }
247
248 /**
249 * Check if MainWP Extensions are Activated or not.
250 *
251 * @param mixed $plugin_slug Plugin Slug.
252 *
253 * @return string Activation warning message.
254 *
255 * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_indexed_extensions_infor()
256 */
257 public static function after_extensions_plugin_row( $plugin_slug ) {
258 $extensions = MainWP_Extensions_Handler::get_indexed_extensions_infor();
259 if ( ! isset( $extensions[ $plugin_slug ] ) ) {
260 return;
261 }
262
263 if ( ! isset( $extensions[ $plugin_slug ]['apiManager'] ) || ! $extensions[ $plugin_slug ]['apiManager'] ) {
264 return;
265 }
266
267 if ( isset( $extensions[ $plugin_slug ]['activated_key'] ) && 'Activated' === $extensions[ $plugin_slug ]['activated_key'] ) {
268 return;
269 }
270
271 $slug = basename( $plugin_slug, '.php' );
272
273 $activate_notices = get_user_option( 'mainwp_hide_activate_notices' );
274 if ( is_array( $activate_notices ) && isset( $activate_notices[ $slug ] ) ) {
275 return;
276 }
277 ?>
278 <style type="text/css">
279 tr[data-plugin="<?php echo esc_attr( $plugin_slug ); ?>"] {
280 box-shadow: none;
281 }
282 </style>
283 <tr class="plugin-update-tr active" slug="<?php echo esc_attr( $slug ); ?>"><td colspan="4" class="plugin-update colspanchange"><div class="update-message api-deactivate">
284 <?php /* translators: 1: Opening link tag, 2: Closing link tag */ printf( esc_html__( 'You have a MainWP Extension that does not have an active API entered. This means you will not receive updates or support. Please visit the %1$sExtensions%2$s page and enter your API.', 'mainwp' ), '<a href="admin.php?page=Extensions">', '</a>' ); ?>
285 <span class="mainwp-right"><a href="#" class="mainwp-activate-notice-dismiss" ><i class="times circle icon"></i> <?php esc_html_e( 'Dismiss', 'mainwp' ); ?></a></span>
286 </div></td></tr>
287 <?php
288 }
289
290 /**
291 * MainWP Version 4 update Notice.
292 *
293 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
294 */
295 public static function mainwp_4_update_notice() {
296 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_4' ) ) {
297 ?>
298 <div class="ui icon message yellow">
299 <i class="exclamation circle icon"></i>
300 <strong><?php echo esc_html__( 'Important Notice: ', 'mainwp' ); ?></strong>&nbsp;<?php /* translators: 1: Opening link tag, 2: Closing link tag with icon */ printf( esc_html__( 'MainWP Version 4 is a major upgrade from MainWP Version 3. Please, read this&nbsp; %1$supdating FAQ%2$s.', 'mainwp' ), '<a href="https://docs.mainwp.com/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. ?>
301 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_4"></i>
302 </div>
303 <?php
304 }
305 }
306
307 /**
308 * MainWP Version ver 5 update Notice.
309 *
310 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
311 */
312 public static function mainwp_ver5_update_notice() {
313 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_version5' ) ) {
314 ?>
315 <div class="ui modal" id="mainwp-v5-update-notice-modal">
316 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_version5"></i>
317 <div class="header">
318 <?php echo esc_html__( 'MainWP 5.0 Update Notice', 'mainwp' ); ?>
319 </div>
320 <div class="content">
321 <h3 class="ui header">
322 <i class="sync alternate icon"></i>
323 <div class="content">
324 <?php echo esc_html__( 'Hard Refresh Required', 'mainwp' ); ?>
325
326 </div>
327 </h3>
328 <div class="ui hidden divider"></div>
329 <div><?php echo esc_html__( 'Please perform a hard refresh of your browser to ensure optimal performance and access to all new features.', 'mainwp' ); ?></div>
330 <br/>
331 <div><?php echo esc_html__( 'This step is crucial for loading the latest updates effectively.', 'mainwp' ); ?></div>
332 <div class="ui list">
333 <div class="item"><i class="windows icon"></i> <?php echo esc_html__( 'Windows users: Press `Ctrl + F5`', 'mainwp' ); ?></div>
334 <div class="item"><i class="apple icon"></i> <?php echo esc_html__( 'Mac users: Press `Command + R`', 'mainwp' ); ?></div>
335 <div class="item"><i class="linux icon"></i> <?php echo esc_html__( 'Linux users: Press `F5`', 'mainwp' ); ?></div>
336 </div>
337
338 <div class="ui divider"></div>
339
340 <h3 class="ui header">
341 <i class="linkify icon"></i>
342 <div class="content">
343 <?php echo esc_html__( 'Extensions License Reactivation Required', 'mainwp' ); ?>
344
345 </div>
346 </h3>
347 <div class="ui hidden divider"></div>
348 <div><?php echo esc_html__( 'As part of our upgrade to MainWP Dashboard version 5, we\'ve deactivated extension licenses to verify their validity and ensure everything is up to date.', 'mainwp' ); ?></div>
349 <br/>
350 <div><?php echo esc_html__( 'Simply click the "Activate Extensions" button on the Extensions page to reactivate all your Pro extension licenses in one go. It\'s quick and easy!', 'mainwp' ); ?></div>
351
352 <div class="ui divider"></div>
353
354 <div><?php echo esc_html__( 'We appreciate your understanding and cooperation in keeping your MainWP ecosystem secure and efficient. Need help? Reach out to our support team', 'mainwp' ); ?></div>
355 <div class="ui hidden divider"></div>
356 <div><?php echo esc_html__( 'Thank you for using MainWP!', 'mainwp' ); ?></div>
357 </div>
358 </div>
359 <script type="text/javascript">
360 jQuery( document ).ready( function() {
361 jQuery( '#mainwp-v5-update-notice-modal' ).modal({
362 onHidden: function () {
363 let notice_id = jQuery( '#mainwp-v5-update-notice-modal' ).find('.mainwp-notice-dismiss').attr('notice-id');
364 let data = {
365 action: 'mainwp_notice_status_update'
366 };
367 data['notice_id'] = notice_id;
368 jQuery.post(ajaxurl, mainwp_secure_data(data), function () { });
369 },
370 }).modal('show');
371 });
372 </script>
373 <?php
374 }
375 }
376
377 /**
378 * MainWP Version ver 5 update Notice.
379 *
380 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
381 */
382 public static function mainwp_ver502_update_notice() {
383 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_version502' ) ) {
384 ?>
385 <div class="ui modal" id="mainwp-v502-update-notice-modal">
386 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_version502"></i>
387 <div class="header">
388 <?php echo esc_html__( 'MainWP 5.0.2 Update Notice', 'mainwp' ); ?>
389 </div>
390 <div class="content">
391 <div><?php echo esc_html__( 'Please perform a hard refresh of your browser to ensure optimal performance and access to all new features.', 'mainwp' ); ?></div>
392 <br/>
393 <div><?php echo esc_html__( 'This step is crucial for loading the latest updates effectively.', 'mainwp' ); ?></div>
394 <div class="ui list">
395 <div class="item"><i class="windows icon"></i> <?php echo esc_html__( 'Windows users: Press `Ctrl + F5`', 'mainwp' ); ?></div>
396 <div class="item"><i class="apple icon"></i> <?php echo esc_html__( 'Mac users: Press `Command + R`', 'mainwp' ); ?></div>
397 <div class="item"><i class="linux icon"></i> <?php echo esc_html__( 'Linux users: Press `F5`', 'mainwp' ); ?></div>
398 </div>
399 </div>
400 </div>
401 <script type="text/javascript">
402 jQuery( document ).ready( function() {
403 jQuery( '#mainwp-v502-update-notice-modal' ).modal({
404 onHidden: function () {
405 let notice_id = jQuery( '#mainwp-v502-update-notice-modal' ).find('.mainwp-notice-dismiss').attr('notice-id');
406 let data = {
407 action: 'mainwp_notice_status_update'
408 };
409 data['notice_id'] = notice_id;
410 jQuery.post(ajaxurl, mainwp_secure_data(data), function () { });
411 },
412 }).modal('show');
413 });
414 </script>
415 <?php
416 }
417 }
418
419 /**
420 * MainWP Version ver 6.1 update Notice.
421 *
422 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
423 */
424 public static function mainwp_ver61_update_notice() {
425 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_version61' ) && MainWP_DB::instance()->get_websites_count() > 0 ) {
426 ?>
427 <div class="ui attention message">
428 <div class="header"><?php esc_html_e( 'Important Rollback Notice', 'mainwp' ); ?></div>
429 <div>
430 <p><?php esc_html_e( 'Version 6.1 includes internal connection handling changes. If you roll back to a version earlier than 6.1, child sites may temporarily lose connection to your MainWP Dashboard.', 'mainwp' ); ?></p>
431 <p><?php esc_html_e( 'This can be easily resolved by reconnecting the sites. To reconnect multiple sites at once, go to the Manage Sites page and use the Reconnect bulk action.', 'mainwp' ); ?></p>
432 <a href="https://docs.mainwp.com/sites/management/manage-child-sites#reconnect-a-child-site" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Learn how to reconnect sites.', 'mainwp' ); ?></a>
433 </div>
434 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_version61"></i>
435 </div>
436 <?php
437 }
438 }
439
440 /**
441 * MainWP Version ver 5 update Notice.
442 *
443 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
444 */
445 public static function mainwp_ver5_update_clear_cache_notice() {
446 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_ver5_clear_cache' ) ) {
447 ?>
448 <div class="ui message info">
449 <div><?php echo esc_html__( 'Please perform a hard refresh of your browser to ensure optimal performance and access to all new features. This step is crucial for loading the latest updates effectively.', 'mainwp' ); ?></div>
450 <div class="ui list">
451 <div class="item"><?php echo esc_html__( 'Windows users: Press `Ctrl + F5`', 'mainwp' ); ?></div>
452 <div class="item"><?php echo esc_html__( 'Mac users: Press `Command + R`', 'mainwp' ); ?></div>
453 <div class="item"><?php echo esc_html__( 'Linux users: Press `F5`', 'mainwp' ); ?></div>
454 </div>
455 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_ver5_clear_cache"></i>
456 </div>
457 <?php
458 }
459 }
460
461
462 /**
463 * Render Administration Notice.
464 *
465 * @uses \MainWP\Dashboard\MainWP_System::is_mainwp_pages()
466 * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::check_auto_update_plugin()
467 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_openssl_config_warning()
468 */
469 public static function admin_notices() {
470
471 static::mainwp_tmpfile_check();
472
473 static::render_extension_update_failure_notice();
474
475 static::render_notice_config_warning();
476
477 static::render_notice_multi_sites();
478
479 static::render_wp_mail_warning();
480
481 static::render_consumer_secret_migration_failed_notice();
482
483 static::render_secure_priv_key_connection();
484
485 static::render_notice_php_version8();
486
487 static::render_notice_trust_update();
488
489 static::render_mainwp_themes_deprecation_notice();
490
491 static::render_tours_notice();
492
493 static::check_rating_notice();
494
495 static::render_browser_extensions_notice();
496
497 }
498
499 /**
500 * Render the repeated Add-on update-check failure notice.
501 */
502 public static function render_extension_update_failure_notice() {
503 if ( ! \mainwp_current_user_can( 'dashboard', 'manage_extensions' ) ) {
504 return;
505 }
506
507 $notice_id = MainWP_System_Handler::instance()->get_extension_update_failure_notice_id();
508 if ( '' === $notice_id ) {
509 return;
510 }
511
512 $is_extensions_page = isset( $_GET['page'] ) && 'Extensions' === sanitize_text_field( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
513 if ( ! $is_extensions_page && ! MainWP_Utility::show_mainwp_message( 'notice', $notice_id ) ) {
514 return;
515 }
516 ?>
517 <div class="ui yellow message mainwp-extension-update-failure-notice" style="margin-bottom:0;">
518 <div class="header"><?php esc_html_e( 'Unable to check for Add-on updates', 'mainwp' ); ?></div>
519 <?php if ( $is_extensions_page ) : ?>
520 <p><?php esc_html_e( 'MainWP is unable to check one or more Add-ons for updates. Retry the check below.', 'mainwp' ); ?></p>
521 <button
522 type="button"
523 id="mainwp-extension-update-check-retry"
524 class="ui mini yellow button"
525 data-failed-text="<?php esc_attr_e( 'The update check is still failing. Make sure your MainWP Dashboard can connect to mainwp.com, then try again.', 'mainwp' ); ?>"
526 ><?php esc_html_e( 'Retry update checks', 'mainwp' ); ?></button>
527 <span id="mainwp-extension-update-check-retry-status" class="ui small red text" aria-live="polite"></span>
528 <?php else : ?>
529 <p><?php esc_html_e( 'MainWP is unable to check one or more Add-ons for updates. Open the Add-ons page to retry the check.', 'mainwp' ); ?></p>
530 <a class="ui mini yellow button" href="<?php echo esc_url( admin_url( 'admin.php?page=Extensions' ) ); ?>"><?php esc_html_e( 'Review Add-ons', 'mainwp' ); ?></a>
531 <i class="close icon mainwp-notice-dismiss" notice-id="<?php echo esc_attr( $notice_id ); ?>"></i>
532 <?php endif; ?>
533 </div>
534 <?php
535 }
536
537 /**
538 * Render MainWP themes deprecation notice.
539 *
540 * @uses \MainWP\Dashboard\MainWP_Settings::get_instance()
541 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
542 */
543 public static function render_mainwp_themes_deprecation_notice() {
544 $selected_theme = MainWP_Settings::get_instance()->get_selected_theme();
545 $legacy_themes = array( 'dark', 'wpadmin', 'minimalistic', 'classic', 'default-2024' );
546
547 if ( in_array( $selected_theme, $legacy_themes, true ) && MainWP_Utility::show_mainwp_message( 'notice', 'mainwp_themes_deprecation_notice' ) ) {
548 $message_class = 'default-2024' === $selected_theme ? 'attention' : 'yellow';
549 ?>
550 <div class="ui <?php echo esc_attr( $message_class ); ?> message">
551 <div class="header"><?php esc_html_e( 'MainWP Dashboard Theme Support Notice', 'mainwp' ); ?></div>
552 <div>
553 <?php
554 /* translators: 1: Opening anchor tag, 2: Closing anchor tag */
555 printf( esc_html__( 'You\'re currently using a legacy or custom MainWP theme. With MainWP v6, only Light and Dark themes are actively maintained. Your current theme will keep working for now, but it may not receive updates and could have visual issues in future releases. Switch anytime in %1$sMainWP → Tools%2$s.', 'mainwp' ), '<a href="' . esc_url( admin_url( 'admin.php?page=MainWPTools' ) ) . '">', '</a>' );
556 ?>
557 </div>
558 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp_themes_deprecation_notice"></i>
559 </div>
560 <?php
561 }
562 }
563
564 /**
565 * Method mainwp_tmpfile_check()
566 *
567 * Checks if the `tmpfile()` PHP function is disabled.
568 */
569 public static function mainwp_tmpfile_check() {
570 if ( MainWP_Demo_Handle::is_instawp_site() ) {
571 return;
572 }
573 if ( ! static::is_tmpfile_enable() && MainWP_Utility::show_mainwp_message( 'notice', 'tmpfile_notice' ) ) {
574 ?>
575 <div class="ui red message">
576 <div class="header"><?php esc_html_e( 'Server configuration required (tmpfile disabled)', 'mainwp' ); ?></div>
577 <div><?php esc_html_e( 'Your server has tmpfile() disabled. MainWP uses temporary files for some background tasks, so parts of the Dashboard may not work correctly until this is enabled. Please ask your host to enable tmpfile() (PHP function).', 'mainwp' ); ?></div>
578 <i class="close icon mainwp-notice-dismiss" notice-id="tmpfile_notice"></i>
579 </div>
580 <?php
581 }
582 }
583
584 /**
585 * Method is_tmpfile_enable()
586 *
587 * Checks if the `tmpfile()` PHP function is enable.
588 */
589 public static function is_tmpfile_enable() {
590 if ( ! function_exists( '\tmpfile' ) ) {
591 return false;
592 }
593 $disabled_functions = ini_get( 'disable_functions' );
594 return '' !== $disabled_functions && false !== stripos( $disabled_functions, 'tmpfile' ) ? false : true;
595 }
596
597 /**
598 * Renders Browsers extensions notice.
599 *
600 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
601 */
602 public static function render_browser_extensions_notice() {
603 if ( MainWP_DB::instance()->get_websites_count() > 4 && MainWP_Utility::show_mainwp_message( 'notice', 'mainwp_browser_extensions_notice' ) ) {
604 ?>
605 <div class="ui info message">
606 <div class="header"><?php esc_html_e( 'Track Updates and Non-MainWP Changes from Your Browser!', 'mainwp' ); ?></div>
607 <div><?php esc_html_e( 'The MainWP Browser Extension helps you easily track available updates across all your connected Child Sites, including changes to your plugins and themes status made outside your MainWP Dashboard.', 'mainwp' ); ?></div>
608 <div><?php esc_html_e( 'The extension quickly connects to your MainWP Dashboard via MainWP REST API, eliminating the need to log in to your MainWP Dashboard repeatedly to check available updates and non-MainWP changes.', 'mainwp' ); ?></div>
609 <br/>
610 <div>
611 <a href="https://chrome.google.com/webstore/detail/mainwp-browser-extension/kjlehednpnfgplekjminjpocdechbnge" target="_blank" class="ui green tiny button"><i class="chrome icon"></i> <?php echo esc_html__( 'Get Chrome Extension', 'mainwp' ); ?></a>
612 <a href="https://mainwp.com/mainwp-browser-extension/" target="_blank" class="ui tiny button"><?php echo esc_html__( 'Read More', 'mainwp' ); // NOSONAR - noopener - open safe. ?></a>
613 </div>
614 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp_browser_extensions_notice"></i>
615 </div>
616 <?php
617 }
618 }
619
620 /**
621 * Renders Browsers extensions notice.
622 *
623 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
624 */
625 public static function render_secure_priv_key_connection() {
626 if ( MainWP_DB::instance()->get_websites_count() > 0 && ! static::check_keys_encrypted() && MainWP_Utility::show_mainwp_message( 'notice', 'mainwp_secure_priv_key_notice' ) ) {
627 ?>
628 <div class="ui attention message">
629 <div class="header"><?php esc_html_e( 'New Security Feature: OpenSSL Key Encryption', 'mainwp' ); ?></div>
630 <div><?php esc_html_e( 'To enhance security, we\'ve added a feature to encrypt your private keys stored in the database. This provides an extra layer of protection in the unlikely event your database is compromised.', 'mainwp' ); ?> <a href="https://docs.mainwp.com/sites/management/mainwp-dashboard-settings#force-new-openssl-keys" target="_blank"><?php esc_html_e( 'Learn more here.', 'mainwp' ); ?></a></div>
631 <p><button class="ui green mini button" id="increase-connection-security-btn"><?php echo esc_html__( 'Encrypt Keys Now', 'mainwp' ); ?></button></p>
632 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp_secure_priv_key_notice"></i>
633 </div>
634 <?php
635 }
636 }
637
638 /**
639 * Method check_keys_encrypted().
640 *
641 * @return bool Keys encrypted or not.
642 */
643 public static function check_keys_encrypted() {
644 if ( get_option( 'mainwp_keys_is_encrypted' ) ) {
645 return true;
646 }
647 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, true ) );
648 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
649 // try to decrypt priv key.
650 $de_privkey = MainWP_Encrypt_Data_Lib::instance()->decrypt_privkey( base64_decode( $website->privkey ), $website->id ); // phpcs:ignore -- NOSONAR - base64_encode trust.
651 if ( ! empty( $de_privkey ) ) {
652 update_option( 'mainwp_keys_is_encrypted', 1 );
653 return true;
654 }
655 }
656 return false;
657 }
658
659
660 /**
661 * Renders wp_mail warning.
662 */
663 public static function render_wp_mail_warning() {
664 $mail_failed = get_option( 'mainwp_notice_wp_mail_failed' );
665 if ( 'yes' === $mail_failed ) {
666 ?>
667 <div class="ui yellow message">
668 <div class="header"><?php esc_html_e( 'Email sending failed (wp_mail)', 'mainwp' ); ?></div>
669 <div><?php esc_html_e( 'Your Dashboard failed to send email using wp_mail(). This may affect alerts, reports, and notifications. Common causes include SMTP/server configuration or a plugin conflict. Check your email setup or contact your host for help.', 'mainwp' ); ?></div>
670 <i class="close icon mainwp-notice-dismiss" notice-id="mail_failed"></i>
671 </div>
672 <?php
673 }
674 }
675
676 /**
677 * Renders a notice when the consumer_secret schema migration did not complete.
678 *
679 * The migration in MainWP_Install::update_optimize_indexes_55() widens
680 * wp_mainwp_api_keys.consumer_secret to varchar(255) so that hashed
681 * secrets fit. If the ALTER TABLE silently fails on the host, modern
682 * bcrypt hashes get truncated and authentication breaks for any newly
683 * created API key. The flag option is set when the post-migration
684 * SHOW COLUMNS check finds the column still narrower than expected.
685 */
686 public static function render_consumer_secret_migration_failed_notice() {
687 $failed_at = get_option( 'mainwp_notice_consumer_secret_migration_failed' );
688 if ( empty( $failed_at ) ) {
689 return;
690 }
691 ?>
692 <div class="ui red message">
693 <div class="header"><?php esc_html_e( 'REST API keys table upgrade did not complete', 'mainwp' ); ?></div>
694 <div>
695 <?php esc_html_e( 'A database upgrade for the REST API keys table did not complete on this site. New API keys created on this version may not authenticate correctly until the upgrade runs successfully. Existing API keys are unaffected. Please contact MainWP support so we can help diagnose the underlying database error.', 'mainwp' ); ?>
696 </div>
697 </div>
698 <?php
699 }
700
701 /**
702 * Renders PHP 8.0 Version Notice.
703 *
704 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
705 */
706 public static function render_notice_php_version8() {
707 $phpver = phpversion();
708 if ( version_compare( $phpver, '8.0', '<' ) ) {
709 $last_hidden = (int) get_user_option( 'lasttime_hidden_phpver_8_0' );
710 if ( time() > $last_hidden + 30 * DAY_IN_SECONDS || MainWP_Utility::show_mainwp_message( 'notice', 'phpver_8_0' ) ) {
711 ?>
712 <div class="ui attention message">
713 <div class="header"><?php esc_html_e( 'Upcoming PHP requirement (Dashboard)', 'mainwp' ); ?></div>
714 <?php esc_html_e( 'In the coming months, MainWP Dashboard will require PHP 8.1+. To avoid issues and stay secure, please update your Dashboard site to a supported version (for example PHP 8.3).', 'mainwp' ); ?>
715 <?php /* translators: 1: Opening link tag, 2: Closing link tag */ printf( esc_html__( 'You can check the list of actively maintained PHP versions %1$shere%2$s.', 'mainwp' ), '<a href="https://www.php.net/supported-versions.php" target="_blank">', '</a>' ); ?>
716 <br/><br/>
717 <strong><?php esc_html_e( 'This change affects only your MainWP Dashboard site, not your connected child sites.', 'mainwp' ); ?></strong>
718 <i class="close icon mainwp-notice-dismiss" notice-id="phpver_8_0"></i>
719 </div>
720 <?php
721 }
722 }
723 }
724
725
726 /**
727 * Renders Guided Tours Notice.
728 *
729 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
730 */
731 public static function render_tours_notice() {
732 if ( MainWP_DB::instance()->get_websites_count() > 4 && 0 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) && MainWP_Utility::show_mainwp_message( 'notice', 'mainwp_guided_tours_notice' ) ) {
733 ?>
734 <div class="ui info message">
735 <div class="header"><?php esc_html_e( 'Enable guided tours?', 'mainwp' ); ?></div>
736 <div><?php esc_html_e( 'Guided tours highlight essential features on each Dashboard page. You can turn them off anytime.', 'mainwp' ); ?></div>
737 <div class="ui hidden divider"></div>
738 <div class="ui form">
739 <div class="field">
740 <div class="ui toggle checkbox">
741 <input type="checkbox" name="mainwp-select-guided-tours-option" onchange="mainwp_guidedtours_onchange(this);" id="mainwp-select-guided-tours-option" <?php echo 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ? 'checked="true"' : ''; ?>>
742 <label for="mainwp-select-guided-tours-option"><?php esc_html_e( 'Select to enable the MainWP Guided Tours.', 'mainwp' ); ?></label>
743 </div>
744 </div>
745 </div>
746 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp_guided_tours_notice"></i>
747 </div>
748 <?php
749 }
750 }
751
752 /**
753 * Renders OpenSSL Error message.
754 *
755 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
756 */
757 public static function render_notice_config_warning() {
758 if ( MainWP_Server_Information_Handler::is_openssl_config_warning() && isset( $_GET['page'] ) && 'SettingsAdvanced' !== $_GET['page'] && MainWP_Utility::show_mainwp_message( 'notice', 'ssl_warn' ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
759 ?>
760 <div class="ui yellow message">
761 <div class="header"><?php esc_html_e( 'OpenSSL configuration required', 'mainwp' ); ?></div>
762 <div><?php esc_html_e( 'MainWP detected that OpenSSL.cnf isn’t configured correctly. This may prevent you from connecting child sites. Fix it in Settings → Advanced. If connections work fine, you can dismiss this message.', 'mainwp' ); ?></div>
763 <i class="close icon mainwp-notice-dismiss" notice-id="ssl_warn"></i>
764 </div>
765 <?php
766 }
767 }
768
769 /** Renders WP Multisite Error Message. */
770 public static function render_notice_multi_sites() {
771 $current_options = get_option( 'mainwp_showhide_events_notice' );
772 if ( ! is_array( $current_options ) ) {
773 $current_options = array();
774 }
775
776 if ( is_multisite() && ( ! isset( $current_options['hide_multi_site_notice'] ) || empty( $current_options['hide_multi_site_notice'] ) ) ) {
777 ?>
778 <div class="ui yellow message">
779 <div class="header"><?php esc_html_e( 'Multisite detected (limited support)', 'mainwp' ); ?></div>
780 <?php esc_html_e( 'MainWP Dashboard is not fully tested on WordPress Multisite, and some features may not work as expected. For the best experience, install MainWP on a single-site WordPress installation.', 'mainwp' ); ?>
781 <i class="close icon mainwp-notice-dismiss" notice-id="multi_site"></i>
782 </div>
783 <?php
784 }
785 }
786
787 /**
788 * Renders MainWP Review Request.
789 *
790 * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_extensions()
791 */
792 public static function check_rating_notice() { // phpcs:ignore -- NOSONAR - complex.
793 $current_options = get_option( 'mainwp_showhide_events_notice' );
794 if ( ! is_array( $current_options ) ) {
795 $current_options = array();
796 }
797
798 $display_request1 = false;
799 $display_request2 = false;
800
801 if ( isset( $current_options['request_reviews1'] ) ) {
802 if ( 'forever' === $current_options['request_reviews1'] ) {
803 $display_request1 = false;
804 } else {
805 $days = intval( $current_options['request_reviews1'] );
806 $start_time = $current_options['request_reviews1_starttime'];
807 $display_request1 = ( ( time() - $start_time ) > $days * 24 * 3600 ) ? true : false;
808 }
809 } else {
810 $current_options['request_reviews1'] = 30;
811 $current_options['request_reviews1_starttime'] = time();
812 update_option( 'mainwp_showhide_events_notice', $current_options );
813 }
814
815 $currentExtensions = MainWP_Extensions_Handler::get_extensions();
816 $has_many_addons = is_array( $currentExtensions ) && count( $currentExtensions ) > 10;
817
818 if ( $display_request1 && $has_many_addons ) {
819 static::render_review_mainwp_notice( true );
820 } elseif ( $display_request1 ) {
821 static::render_review_mainwp_notice( false );
822 }
823 }
824
825 /**
826 * Renders MainWP review request notice.
827 *
828 * Displays a dismissible notice encouraging users to leave a review on WordPress.org.
829 * Message content varies based on whether user has extensions installed.
830 *
831 * @since 6.0.0
832 *
833 * @param bool $addons Whether user has add-ons/extensions installed. Default false.
834 * @return void
835 */
836 public static function render_review_mainwp_notice( $addons = false ) {
837 ?>
838 <div class="ui segment">
839 <div class="ui icon message">
840 <i class="yellow star icon"></i>
841 <div class="content">
842 <div class="header"><?php esc_html_e( 'Enjoying MainWP?', 'mainwp' ); ?></div>
843 <div>
844 <?php if ( $addons ) : ?>
845 <?php esc_html_e( 'You\'ve been using MainWP for a while and it looks like you\'ve built a solid setup with add-ons.', 'mainwp' ); ?>
846 <?php else : ?>
847 <?php esc_html_e( 'You\'ve been using MainWP for a while.', 'mainwp' ); ?>
848 <?php endif; ?>
849 </div>
850 <div><?php esc_html_e( 'If MainWP has been helpful, would you mind leaving a quick review on WordPress.org? It helps others find the plugin and supports ongoing improvements.', 'mainwp' ); ?></div>
851 </div>
852 <div class="" style="float:right">
853 <div class="ui buttons">
854 <a href="https://wordpress.org/support/plugin/mainwp/reviews/#new-post" class="ui green mini button" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Review on WordPress.org', 'mainwp' ); ?></a>
855 <div class="ui floating dropdown icon green mini button" style="opacity:0.85">
856 <i class="dropdown icon"></i>
857 <div class="menu">
858 <a href="https://www.g2.com/products/mainwp/reviews" target="_blank" rel="noopener noreferrer" class="item" style="text-decoration:none!important;"><?php esc_html_e( 'Review on G2', 'mainwp' ); ?></a>
859 <a href="https://www.trustpilot.com/review/mainwp.com" target="_blank" rel="noopener noreferrer" class="item" style="text-decoration:none!important;"><?php esc_html_e( 'Review on Trustpilot', 'mainwp' ); ?></a>
860 </div>
861 </div>
862 </div>
863 <a href="" class="ui mini basic grey button mainwp-events-notice-dismiss" notice="request_reviews1"><?php esc_html_e( 'Remind me later', 'mainwp' ); ?></a>
864 </div>
865 <i class="close icon mainwp-events-notice-dismiss" notice="request_reviews1_forever"></i>
866 </div>
867 </div>
868 <?php
869 }
870
871 /**
872 * Renders MainWP Dashboard & Child Plugin auto update Alert.
873 */
874 public static function render_notice_trust_update() {
875 $current_options = get_option( 'mainwp_showhide_events_notice' );
876 if ( ! is_array( $current_options ) ) {
877 $current_options = array();
878 }
879
880 if ( MainWP_DB::instance()->get_websites_count() > 4 && ( ! isset( $current_options['trust_child'] ) || empty( $current_options['trust_child'] ) ) && MainWP_System::is_mainwp_pages() && ! MainWP_Plugins_Handler::check_auto_update_plugin( 'mainwp-child/mainwp-child.php' ) ) {
881 ?>
882 <div class="ui info message">
883 <div class="header"><?php esc_html_e( 'Keep MainWP Child up to date', 'mainwp' ); ?></div>
884 <div><?php esc_html_e( 'Enable automatic updates for MainWP Child on connected sites to improve security and reduce connection issues. You can change this anytime.', 'mainwp' ); ?></div>
885 <p><a id="mainwp_btn_autoupdate_and_trust" class="ui mini green button" href="#"><?php esc_html_e( 'Update MainWP Child Plugin Automatically', 'mainwp' ); ?></a></p>
886 <i class="close icon mainwp-events-notice-dismiss" notice="trust_child"></i>
887 </div>
888 <?php
889 }
890 }
891
892
893
894 /** Renders Send Mail Function may have failed error. */
895 public static function wp_admin_notices() {
896
897 /**
898 * Current pagenow.
899 *
900 * @global string
901 */
902 global $pagenow;
903
904 if ( 'plugins.php' !== $pagenow ) {
905 return;
906 }
907
908 $deactivated_exts = get_transient( 'mainwp_transient_deactivated_incomtible_exts' );
909 if ( $deactivated_exts && is_array( $deactivated_exts ) && ! empty( $deactivated_exts ) ) {
910 ?>
911 <div class='notice notice-error my-dismiss-notice is-dismissible'>
912 <p><?php echo esc_html__( 'MainWP Dashboard 4.0 or newer requires Extensions 4.0 or newer. MainWP will automatically deactivate older versions of MainWP Extensions in order to prevent compatibility problems.', 'mainwp' ); ?></p>
913 </div>
914 <?php
915 }
916 }
917
918 /**
919 * Method admin_footer()
920 *
921 * Renders admin footer.
922 */
923 public static function admin_footer() {
924 $disabled_confirm = get_option( 'mainwp_disable_update_confirmations', 0 );
925 ?>
926 <input type="hidden" id="mainwp-disable-update-confirmations" value="<?php echo intval( $disabled_confirm ); ?>">
927
928 <script type="text/javascript">
929 jQuery( document ).ready(
930 function ()
931 {
932 jQuery( '#adminmenu #collapse-menu' ).hide();
933 }
934 );
935 </script>
936 <?php
937 /**
938 * Filter: mainwp_open_hide_referrer
939 *
940 * Filters whether the MainWP should hide referrer when going to child site.
941 *
942 * @since Unknown
943 */
944 $hide_ref = apply_filters( 'mainwp_open_hide_referrer', false );
945 if ( $hide_ref ) {
946 ?>
947 <script type="text/javascript">
948 jQuery( document ).on( 'click', 'a.mainwp-may-hide-referrer', function ( e ) {
949 e.preventDefault();
950 mainwp_open_hide_referrer( e.target.href );
951 } );
952
953 function mainwp_open_hide_referrer( url ) {
954 let ran = Math.floor( Math.random() * 100 ) + 1;
955 let site = window.open( "", "mainwp_hide_referrer_" + ran );
956 let meta = site.document.createElement( 'meta' );
957 meta.name = "referrer";
958 meta.content = "no-referrer";
959 site.document.getElementsByTagName( 'head' )[0].appendChild( meta );
960 site.document.open();
961 site.document.writeln( '<script type="text/javascript">window.location = "' + url + '";<\/script>' );
962 site.document.close();
963 }
964 </script>
965 <?php
966 }
967 }
968
969 /**
970 * Admin print styles.
971 *
972 * @uses \MainWP\Dashboard\MainWP_System::is_mainwp_pages()
973 */
974 public static function admin_print_styles() {
975 ?>
976 <style>
977 <?php
978 if ( MainWP_System::is_mainwp_pages() ) {
979 ?>
980 #wpbody-content > div.update-nag,
981 #wpbody-content > div.updated {
982 margin-left: 190px;
983 }
984 html.wp-toolbar{
985 padding-top: 0 !important;
986 }
987 <?php
988 }
989 ?>
990 .mainwp-checkbox:before {
991 content: '<?php esc_html_e( 'YES', 'mainwp' ); ?>';
992 }
993 .mainwp-checkbox:after {
994 content: '<?php esc_html_e( 'NO', 'mainwp' ); ?>';
995 }
996 </style>
997 <?php
998 }
999
1000 /**
1001 * Productions site warning.
1002 *
1003 * Renders the warning if the production site is detected.
1004 *
1005 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count()
1006 */
1007 public static function mainwp_warning_notice() {
1008 if ( 'yes' === get_option( 'mainwp_installation_warning_hide_the_notice' ) ) {
1009 return;
1010 }
1011 if ( MainWP_DB::instance()->get_websites_count() > 0 ) {
1012 return;
1013 } else {
1014 $plugins = get_plugins();
1015 if ( ! is_array( $plugins ) || count( $plugins ) <= 4 ) {
1016 return;
1017 }
1018 }
1019 ?>
1020 <div class="ui blue message">
1021 <h4><?php esc_html_e( 'This appears to be a production site', 'mainwp' ); ?></h4>
1022 <?php esc_html_e( 'We HIGHLY recommend a NEW WordPress install for your MainWP Dashboard.', 'mainwp' ); ?> <?php /* translators: %s: Example subdomain string */ printf( esc_html__( 'Using a new WordPress install will help to cut down on plugin conflicts and other issues that can be caused by trying to run your MainWP Dashboard off an active site. Most hosting companies provide free subdomains %s and we recommend creating one if you do not have a specific dedicated domain to run your MainWP Dashboard.', 'mainwp' ), '("<strong>demo.yourdomain.com</strong>")' ); ?>
1023 <br /><br />
1024 <a href="#" class="ui green mini button" id="remove-mainwp-installation-warning"><?php esc_html_e( 'I have read the warning and I want to proceed', 'mainwp' ); ?></a>
1025 </div>
1026 <?php
1027 }
1028
1029 /** Render Admin Header */
1030 public static function admin_head() {
1031 ?>
1032 <script type="text/javascript">let mainwp_ajax_nonce = "<?php echo esc_js( wp_create_nonce( 'mainwp_ajax' ) ); ?>", mainwp_js_nonce = "<?php echo esc_js( wp_create_nonce( 'mainwp_nonce' ) ); ?>";</script>
1033 <?php
1034 if ( ( MainWP_System::is_mainwp_pages() || ( isset( $_GET['page'] ) && 'mainwp-setup' === $_GET['page'] ) ) && get_option( 'mainwp_enable_guided_tours', 0 ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1035 static::mainwp_usetiful_tours();
1036 }
1037 }
1038
1039 /**
1040 * Render usetiful tours.
1041 */
1042 public static function mainwp_usetiful_tours() {
1043 echo "
1044 <script>
1045 (function (w, d, s) {
1046 console.log('init usetifulScript');
1047 let a = d.getElementsByTagName('head')[0];
1048 let r = d.createElement('script');
1049 r.async = 1;
1050 r.src = s;
1051 r.setAttribute('id', 'usetifulScript');
1052 r.dataset.token = '480fa17b0507a1c60abba94bfdadd0a7';
1053 a.appendChild(r);
1054 })(window, document, 'https://www.usetiful.com/dist/usetiful.js');</script>
1055 ";
1056 }
1057
1058 /**
1059 * MainWP Admin body CSS class attributes.
1060 *
1061 * @param mixed $class_string MainWP CSS Class attributes.
1062 *
1063 * @return string $class_string The CSS attributes to add to the page.
1064 *
1065 * @uses \MainWP\Dashboard\MainWP_System::is_mainwp_pages()
1066 */
1067 public static function admin_body_class( $class_string ) { // phpcs:ignore -- NOSONAR - complex.
1068 if ( MainWP_System::is_mainwp_pages() ) {
1069 $class_string .= ' mainwp-ui mainwp-ui-page ';
1070 $class_string .= ' mainwp-ui-leftmenu ';
1071
1072 $selected_theme = MainWP_Settings::get_instance()->get_selected_theme();
1073 if ( ! empty( $selected_theme ) ) {
1074 $class_string .= ' mainwp-custom-theme ';
1075 }
1076
1077 if ( ! empty( $selected_theme ) && is_string( $selected_theme ) ) {
1078 $class_string .= ' mainwp-' . $selected_theme . '-theme ';
1079 } else {
1080 $class_string .= ' mainwp-classic-theme ';
1081 }
1082
1083 $siteViewMode = MainWP_Utility::get_siteview_mode();
1084 if ( 'grid' === $siteViewMode ) {
1085 $class_string .= ' mainwp-sites-grid-view ';
1086 } else {
1087 $class_string .= ' mainwp-sites-table-view ';
1088 }
1089
1090 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1091 if ( isset( $_GET['page'] ) && 'managesites' === $_GET['page'] && isset( $_GET['dashboard'] ) && ! empty( $_GET['dashboard'] ) ) {
1092 $class_string .= ' mainwp-individual-site-overview ';
1093 }
1094
1095 if ( isset( $_GET['page'] ) && 'ManageClients' === $_GET['page'] && isset( $_GET['client_id'] ) && ! empty( $_GET['client_id'] ) ) {
1096 $class_string .= ' mainwp-individual-client-overview ';
1097 }
1098 if ( isset( $_GET['page'] ) && ( 'CostTrackerSettings' === $_GET['page'] || 'ServerInformation' === $_GET['page'] || 'ServerInformationCron' === $_GET['page'] || 'ErrorLog' === $_GET['page'] || 'ActionLogs' === $_GET['page'] || 'PluginPrivacy' === $_GET['page'] || 'Settings' === $_GET['page'] || 'SettingsAdvanced' === $_GET['page'] || 'SettingsMonitors' === $_GET['page'] || 'SettingsEmail' === $_GET['page'] || 'PremiumUpdates' === $_GET['page'] || 'MainWPTools' === $_GET['page'] || 'SettingsInsights' === $_GET['page'] || 'SettingsApiBackups' === $_GET['page'] || 'MonitoringSettings' === $_GET['page'] ) ) {
1099 $class_string .= ' mainwp-individual-site-view ';
1100 }
1101 if ( isset( $_GET['page'] ) && 'CostTrackerAdd' !== $_GET['page'] && ( ( isset( $_GET['id'] ) && ! empty( $_GET['id'] ) ) || ( isset( $_GET['dashboard'] ) && ! empty( $_GET['dashboard'] ) ) || ( isset( $_GET['updateid'] ) && ! empty( $_GET['updateid'] ) ) || ( isset( $_GET['monitor_wpid'] ) && ! empty( $_GET['monitor_wpid'] ) ) || ( isset( $_GET['emailsettingsid'] ) && ! empty( $_GET['emailsettingsid'] ) ) || ( isset( $_GET['scanid'] ) && ! empty( $_GET['scanid'] ) ) ) ) {
1102 $class_string .= ' mainwp-individual-site-view ';
1103 }
1104 // phpcs:enable
1105 $class_string = apply_filters( 'mainwp_page_admin_body_class', $class_string );
1106 }
1107 return $class_string;
1108 }
1109
1110 /**
1111 * Method render_footer_content()
1112 *
1113 * Render footer content.
1114 *
1115 * @param mixed $websites The websites object.
1116 * @param int $current_wpid The current website id.
1117 *
1118 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1119 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
1120 * @uses \MainWP\Dashboard\MainWP_Utility::get_nice_url()
1121 */
1122 public static function render_footer_content( $websites, $current_wpid = false ) { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated.
1123 if ( is_array( $websites ) ) {
1124 $count = count( $websites );
1125 for ( $i = 0; $i < $count; $i++ ) {
1126 $website = $websites[ $i ];
1127 echo '<input type="hidden" name="dashboard_wp_ids[]" class="dashboard_wp_id" error-status="' . ( empty( $website->sync_errors ) ? 0 : 1 ) . '" value="' . intval( $website->id ) . '" />';
1128 }
1129 } elseif ( false !== $websites ) {
1130 while ( $website = MainWP_DB::fetch_object( $websites ) ) {
1131 echo '<input type="hidden" name="dashboard_wp_ids[]" class="dashboard_wp_id" error-status="' . ( empty( $website->sync_errors ) ? 0 : 1 ) . '" value="' . intval( $website->id ) . '" />';
1132 }
1133 }
1134 /**
1135 * Action: mainwp_admin_footer
1136 *
1137 * Fires at the bottom of MainWP content.
1138 *
1139 * @since Unknown
1140 */
1141 do_action( 'mainwp_admin_footer' );
1142 MainWP_UI::render_select_mainwp_themes_modal();
1143 MainWP_UI::render_install_extensions_promo_modal();
1144 ?>
1145 <div class="ui modal" id="mainwp-sync-sites-modal" current-wpid="<?php echo intval( $current_wpid ); ?>">
1146 <i class="mainwp-modal-close close icon"></i>
1147 <div class="header"><?php esc_html_e( 'Data Synchronization', 'mainwp' ); ?></div>
1148 <div class="ui green progress mainwp-modal-progress">
1149 <div class="bar"><div class="progress"></div></div>
1150 <div class="label"></div>
1151 </div>
1152 <div class="scrolling content mainwp-modal-content">
1153 <div class="sync-sites-content-massage"></div>
1154 <div class="ui middle aligned divided list" id="sync-sites-status">
1155 <?php
1156 if ( is_array( $websites ) ) {
1157 $count = count( $websites );
1158 for ( $i = 0; $i < $count; $i++ ) {
1159 $site_name = $website->name;
1160 $website = $websites[ $i ];
1161 $is_sync_err = ( '' !== $website->sync_errors ) ? true : false;
1162 ?>
1163 <div class="item <?php echo $is_sync_err ? 'disconnected-site' : ''; ?>">
1164 <div class="right floated content">
1165 <div class="sync-site-status" niceurl="<?php echo esc_html( $site_name ); ?>" siteid="<?php echo intval( $website->id ); ?>"><span data-position="left center" data-inverted="" data-tooltip="<?php echo $is_sync_err ? esc_html__( 'Site disconnected', 'mainwp' ) : esc_html__( 'Pending', 'mainwp' ); ?>"><i class="<?php echo $is_sync_err ? 'exclamation red icon' : 'clock outline icon'; ?>"></i></span></div>
1166 </div>
1167 <div class="content">
1168 <?php echo esc_html( $site_name ); ?>
1169 <?php do_action( 'mainwp_sync_popup_content', $website ); ?>
1170 </div>
1171 </div>
1172 <?php
1173 }
1174 } else {
1175 MainWP_DB::data_seek( $websites, 0 );
1176 while ( $website = MainWP_DB::fetch_object( $websites ) ) {
1177 $site_name = $website->name;
1178 $is_sync_err = ( '' !== $website->sync_errors ) ? true : false;
1179 ?>
1180 <div class="item <?php echo $is_sync_err ? 'disconnected-site' : ''; ?>">
1181 <div class="right floated content">
1182 <div class="sync-site-status" niceurl="<?php echo esc_html( $site_name ); ?>" siteid="<?php echo intval( $website->id ); ?>"><span data-position="left center" data-inverted="" data-tooltip="<?php echo $is_sync_err ? esc_html__( 'Site disconnected', 'mainwp' ) : esc_html__( 'Pending', 'mainwp' ); ?>"><i class="<?php echo $is_sync_err ? 'exclamation red icon' : 'clock outline icon'; ?>"></i></span></div>
1183 </div>
1184 <div class="content">
1185 <?php echo esc_html( $site_name ); ?>
1186 <?php do_action( 'mainwp_sync_popup_content', $website ); ?>
1187 </div>
1188 </div>
1189 <?php
1190 }
1191 }
1192 ?>
1193 </div>
1194 </div>
1195 </div>
1196
1197 <div class="ui modal" id="mainwp-prepare-data-modal">
1198 <i class="mainwp-modal-close close icon"></i>
1199 <div class="header"><?php esc_html_e( 'Updating All', 'mainwp' ); ?></div>
1200 <div class="scrolling content mainwp-modal-content">
1201 <div class="sync-sites-content-massage"></div>
1202 </div>
1203 </div>
1204 <input type="hidden" id="sync_selected_site_ids" value="" />
1205 <div class="ui tiny modal" id="mainwp-modal-confirm-select">
1206 <i class="close icon"></i>
1207 <div class="header"><?php esc_html_e( 'Confirmation', 'mainwp' ); ?></div>
1208 <div class="content">
1209 <div class="content-massage"></div>
1210 </div>
1211 <div class="actions">
1212 </div>
1213 </div>
1214 <?php
1215 static::render_comfirm_modal();
1216 }
1217
1218 /**
1219 * Method render_comfirm_modal()
1220 *
1221 * Render comfirm modal box.
1222 */
1223 public static function render_comfirm_modal() {
1224 ?>
1225 <div class="ui tiny modal" id="mainwp-modal-confirm">
1226 <i class="close icon"></i>
1227 <div class="header"><?php esc_html_e( 'Confirmation', 'mainwp' ); ?></div>
1228 <div class="scrolling content">
1229 <div class="content-massage"></div>
1230 <div class="ui mini yellow message hidden update-confirm-notice" ><?php /* translators: 1: Opening link tag, 2: Closing link tag */ printf( esc_html__( 'To disable update confirmations, go to the %1$sSettings%2$s page and disable the "Disable update confirmations" option', 'mainwp' ), '<a href="admin.php?page=Settings">', '</a>' ); ?></div>
1231 <div class="ui form hidden" id="mainwp-confirm-form" style="display:none;">
1232 <div class="ui divider"></div>
1233 <div class="field">
1234 <label></label>
1235 <input type="text" id="mainwp-confirm-input" name="mainwp-confirm-input">
1236 </div>
1237 </div>
1238 </div>
1239 <div class="actions">
1240 <div class="ui two columns grid">
1241 <div class="ui left aligned column">
1242 </div>
1243 <div class="ui right aligned column">
1244 <div class="ui green positive button"><?php esc_html_e( 'Yes, proceed!', 'mainwp' ); ?></div>
1245 </div>
1246 </div>
1247 </div>
1248 </div>
1249 <?php
1250 }
1251
1252 /**
1253 * Method get_plugins_install_check()
1254 *
1255 * Get plugins for install checking.
1256 */
1257 public static function get_plugins_install_check() {
1258 $plugins = array(
1259 array(
1260 'page' => 'Extensions-Mainwp-Pro-Reports-Extension',
1261 'slug' => 'mainwp-child-reports/mainwp-child-reports.php',
1262 'name' => 'MainWP Child Reports',
1263 ),
1264 array(
1265 'page' => 'Extensions-Mainwp-Client-Reports-Extension',
1266 'slug' => 'mainwp-child-reports/mainwp-child-reports.php',
1267 'name' => 'MainWP Child Reports',
1268 ),
1269 array(
1270 'page' => 'Extensions-Mainwp-Backwpup-Extension',
1271 'slug' => 'backwpup/backwpup.php',
1272 'name' => 'BackWPup',
1273 ),
1274 array(
1275 'page' => 'Extensions-Mainwp-Ithemes-Security-Extension',
1276 'slug' => 'better-wp-security/better-wp-security.php',
1277 'slug_pro' => 'ithemes-security-pro/ithemes-security-pro.php',
1278 'name' => 'Solid Security Integration',
1279 ),
1280 array(
1281 'page' => 'Extensions-Mainwp-Updraftplus-Extension',
1282 'slug' => 'updraftplus/updraftplus.php',
1283 'name' => 'UpdraftPlus',
1284 ),
1285 array(
1286 'page' => 'Extensions-Mainwp-Wordfence-Extension',
1287 'slug' => 'wordfence/wordfence.php',
1288 'name' => 'Wordfence',
1289 ),
1290 array(
1291 'page' => 'Extensions-Wordpress-Seo-Extension',
1292 'slug' => 'wordpress-seo/wp-seo.php',
1293 'name' => 'Yoast SEO',
1294 ),
1295 array(
1296 'page' => 'Extensions-Mainwp-Jetpack-Protect-Extension',
1297 'slug' => 'jetpack-protect/jetpack-protect.php',
1298 'name' => 'Jetpack Protect',
1299 ),
1300 array(
1301 'page' => 'Extensions-Mainwp-Jetpack-Scan-Extension',
1302 'slug' => 'jetpack-protect/jetpack-protect.php', // tweaked: to requires install the JP protect plugin.
1303 'slug_pro' => 'jetpack/jetpack.php',
1304 'name' => 'Jetpack Protect',
1305 ),
1306 );
1307 return apply_filters( 'mainwp_plugins_install_checks', $plugins );
1308 }
1309
1310 /**
1311 * Render plugins install check modal.
1312 * for the exntesion overview page with the missing install plugin only.
1313 */
1314 public static function render_plugins_install_check() { // phpcs:ignore -- NOSONAR - complex function.
1315
1316 $plugins_to_checks = static::get_plugins_install_check();
1317
1318 $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1319
1320 $plugin_check = MainWP_Utility::get_sub_array_having( $plugins_to_checks, 'page', $page );
1321
1322 if ( ! empty( $plugin_check ) ) {
1323 $plugin_check = current( $plugin_check );
1324 }
1325
1326 if ( empty( $plugin_check ) ) {
1327 return;
1328 }
1329
1330 // if is not overview extension page return.
1331 if ( isset( $_GET['tab'] ) && 'overview' !== $_GET['tab'] && 'dashboard' !== $_GET['tab'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1332 return;
1333 }
1334
1335 $plugin_slug = isset( $plugin_check['slug'] ) ? $plugin_check['slug'] : '';
1336 $slug_pro = isset( $plugin_check['slug_pro'] ) ? $plugin_check['slug_pro'] : '';
1337 $plugin_name = isset( $plugin_check['name'] ) ? $plugin_check['name'] : '';
1338
1339 if ( empty( $plugin_slug ) || empty( $plugin_name ) ) {
1340 return;
1341 }
1342
1343 $check_slug = 'install_check_' . sanitize_text_field( wp_unslash( dirname( $plugin_slug ) ) );
1344 $check_hidetime = MainWP_Utility::get_hide_notice_status( $check_slug );
1345
1346 if ( $check_hidetime && time() < $check_hidetime + 30 * DAY_IN_SECONDS ) {
1347 return;
1348 }
1349
1350 $wpsite_fields = array( 'id', 'name', 'url', 'plugins' );
1351 $sync_fields = array( 'sync_errors', 'totalsize' );
1352 $websites = MainWP_DB::instance()->query(
1353 MainWP_DB::instance()->get_sql_websites_for_current_user_by_params(
1354 array(
1355 'select_wp_fields' => $wpsite_fields,
1356 'select_sync_fields' => $sync_fields,
1357 )
1358 )
1359 );
1360
1361 if ( empty( $websites ) ) {
1362 return;
1363 }
1364
1365 $missing_installed = array();
1366
1367 while ( $websites && $website = MainWP_DB::fetch_object( $websites ) ) {
1368 $site_name = $website->name;
1369 if ( '' !== $website->sync_errors ) {
1370 continue;
1371 }
1372 $not_found = true;
1373 if ( '' !== $website->plugins ) {
1374 $plugins = json_decode( $website->plugins, 1 );
1375 if ( is_array( $plugins ) && ! empty( $plugins ) ) {
1376 foreach ( $plugins as $plugin ) {
1377 if ( isset( $plugin['slug'] ) && ( $plugin_slug === $plugin['slug'] || ( '' !== $slug_pro && $slug_pro === $plugin['slug'] ) ) ) {
1378 $not_found = false;
1379 break; // foreach.
1380 }
1381 }
1382 }
1383 }
1384
1385 if ( $not_found ) {
1386 $missing_installed[ $website->id ] = $website->name;
1387 }
1388 }
1389
1390 if ( empty( $missing_installed ) ) {
1391 return;
1392 }
1393
1394 $items_list_id = 'sync-sites-status';
1395 ?>
1396 <div class="ui modal" id="mainwp-install-check-modal" noti-slug="<?php echo esc_html( $check_slug ); ?>">
1397 <i class="mainwp-modal-close close icon"></i>
1398 <div class="header"><?php esc_html_e( 'Plugin Install Check', 'mainwp' ); ?></div>
1399 <div class="scrolling content mainwp-modal-content">
1400 <div class="ui message" id="mainwp-message-zone-install" style="display:none;"></div>
1401 <div class="ui message blue"><?php /* translators: %s: Plugin name */ printf( esc_html__( 'We have detected the following sites do not have the %s plugin installed. This plugin is required to be installed on your Child Sites for the Extension to work on those sites. Please select sites where you want to install it and click the Install Plugin button. Uncheck any site you don\'t want to add the plugin to or cancel to skip this step. After the installation process, resync your sites to see sites with the newly installed plugin.', 'mainwp' ), esc_html( $plugin_name ) ); ?></div>
1402 <div class="ui middle aligned divided list" id="<?php echo esc_attr( $items_list_id ); ?>">
1403 <?php foreach ( $missing_installed as $siteid => $site_name ) : ?>
1404 <div class="item siteBulkInstall" siteid="<?php echo intval( $siteid ); ?>" status="">
1405 <div class="right floated content">
1406 <span class="queue" data-inverted="" data-position="left center" data-tooltip="<?php echo esc_html__( 'Queued', 'mainwp' ); ?>"><i class="clock outline icon"></i></span>
1407 <span class="progress" data-inverted="" data-position="left center" data-tooltip="<?php echo esc_html__( 'Installing...', 'mainwp' ); ?>" style="display:none"><i class="notched circle loading icon"></i></span>
1408 <span class="status"></span>
1409 </div>
1410 <div class="content">
1411 <div class="ui checkbox checked">
1412 <input type="checkbox" checked="" id="install-check-<?php echo intval( $siteid ); ?>" name="install_checker[]"/>
1413 </div>
1414 <?php echo esc_html( $site_name ); ?>
1415 </div>
1416 </div>
1417 <?php endforeach; ?>
1418 </div>
1419 </div>
1420 <div class="actions mainwp-modal-actions">
1421 <div class="ui two columns grid">
1422 <div class="left aligned column">
1423
1424 </div>
1425 <div class="ui right aligned column">
1426 <input type="button" class="ui green button" id="mainwp-install-check-btn" value="<?php esc_html_e( 'Install Plugin', 'mainwp' ); ?>">
1427 </div>
1428 </div>
1429
1430 </div>
1431 </div>
1432 <script type="text/javascript">
1433 jQuery( document ).ready( function () {
1434 jQuery('#mainwp-install-check-modal').modal({
1435 allowMultiple: false,
1436 closable: false,
1437 onHide: function () {
1438 let noti_id = jQuery('#mainwp-install-check-modal').attr('noti-slug');
1439 mainwp_notice_dismiss(noti_id, 1);
1440 setTimeout(function () {
1441 mainwp_forceReload();
1442 }, 1000);
1443 },
1444 }).modal('show');
1445 jQuery(document).on('click', '#mainwp-install-check-btn', function () {
1446 mainwp_install_check_plugin_prepare( '<?php echo esc_js( rawurlencode( dirname( $plugin_slug ) ) ); ?>' );
1447 return false;
1448 });
1449 });
1450 </script>
1451 <?php
1452 }
1453 }
1454