PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.1.4
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.1.4
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 6.1.4, at class/class-mainwp-system-view.php

1,393 lines 85.0 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 array and strip chartacters "/[^A-Za-z0-9_]/".
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 $strippedText = str_replace( ' ', '_', $pKey );
54 $strippedText = preg_replace( '/[\W]/', '', $strippedText );
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 occured.', esc_html__( 'An error occured.', '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 occured, please contact us.', esc_html__( 'An error occured, 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 occured: ', esc_html__( 'An error occured: ', '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 occured', esc_html__( 'An unspecified error occured', '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, 'Paused import by user.', esc_html__( 'Paused import by user.', 'mainwp' ) );
135 mainwp_add_translation( $mainwpTranslations, 'Continue', esc_html__( 'Continue', 'mainwp' ) );
136 mainwp_add_translation( $mainwpTranslations, 'Continue import.', esc_html__( 'Continue import.', 'mainwp' ) );
137 mainwp_add_translation( $mainwpTranslations, 'Pause', esc_html__( 'Pause', 'mainwp' ) );
138 mainwp_add_translation( $mainwpTranslations, 'Finished', esc_html__( 'Finished', 'mainwp' ) );
139 mainwp_add_translation( $mainwpTranslations, 'Please enter the Site name.', esc_html__( 'Please enter the Site name.', 'mainwp' ) );
140 mainwp_add_translation( $mainwpTranslations, 'Please enter the Site url.', esc_html__( 'Please enter the Site url.', 'mainwp' ) );
141 mainwp_add_translation( $mainwpTranslations, 'Please enter Admin name of the site.', esc_html__( 'Please enter Admin name of the site.', 'mainwp' ) );
142 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' ) );
143 mainwp_add_translation( $mainwpTranslations, 'HTTP error - website does not exist', esc_html__( 'HTTP error - website does not exist', 'mainwp' ) );
144 mainwp_add_translation( $mainwpTranslations, 'No selected Categories', esc_html__( 'No selected Categories', 'mainwp' ) );
145 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' ) );
146 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' ) );
147 mainwp_add_translation( $mainwpTranslations, 'Please enter the username.', esc_html__( 'Please enter the username.', 'mainwp' ) );
148 mainwp_add_translation( $mainwpTranslations, 'Please enter the email.', esc_html__( 'Please enter the email.', 'mainwp' ) );
149 mainwp_add_translation( $mainwpTranslations, 'Please enter the password.', esc_html__( 'Please enter the password.', 'mainwp' ) );
150 mainwp_add_translation( $mainwpTranslations, 'Please select a valid role.', esc_html__( 'Please select a valid role.', 'mainwp' ) );
151 mainwp_add_translation( $mainwpTranslations, 'Loading previous page..', esc_html__( 'Loading previous page..', 'mainwp' ) );
152 mainwp_add_translation( $mainwpTranslations, 'Loading next page..', esc_html__( 'Loading next page..', 'mainwp' ) );
153 mainwp_add_translation( $mainwpTranslations, 'Searching the WordPress repository..', esc_html__( 'Searching the WordPress repository..', 'mainwp' ) );
154 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' ) );
155 mainwp_add_translation( $mainwpTranslations, 'Queued', esc_html__( 'Queued', 'mainwp' ) );
156 mainwp_add_translation( $mainwpTranslations, 'In progress', esc_html__( 'In progress', 'mainwp' ) );
157 mainwp_add_translation( $mainwpTranslations, 'Preparing %1 installation.', esc_html__( 'Preparing %1 installation.', 'mainwp' ) );
158 mainwp_add_translation( $mainwpTranslations, 'Installation successful', esc_html__( 'Installation successful', 'mainwp' ) );
159 mainwp_add_translation( $mainwpTranslations, 'Installation failed', esc_html__( 'Installation failed', 'mainwp' ) );
160 mainwp_add_translation( $mainwpTranslations, 'Please select websites or tags to install files.', esc_html__( 'Please select websites or tags to install files.', 'mainwp' ) );
161 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' ) );
162 mainwp_add_translation( $mainwpTranslations, 'Backupfile on child site created successfully.', esc_html__( 'Backupfile on child site created successfully.', 'mainwp' ) );
163 mainwp_add_translation( $mainwpTranslations, 'Downloading the file.', esc_html__( 'Downloading the file.', 'mainwp' ) );
164 mainwp_add_translation( $mainwpTranslations, 'Download from child completed.', esc_html__( 'Download from child completed.', 'mainwp' ) );
165 mainwp_add_translation( $mainwpTranslations, 'Please wait while we are saving your note', esc_html__( 'Please wait while we are saving your note', 'mainwp' ) );
166 mainwp_add_translation( $mainwpTranslations, 'Note saved.', esc_html__( 'Note saved.', 'mainwp' ) );
167 mainwp_add_translation( $mainwpTranslations, 'An error occured while saving your message.', esc_html__( 'An error occured while saving your message.', 'mainwp' ) );
168 mainwp_add_translation( $mainwpTranslations, 'Please search and select users for update password.', esc_html__( 'Please search and select users for update password.', 'mainwp' ) );
169 mainwp_add_translation( $mainwpTranslations, 'All', esc_html__( 'All', 'mainwp' ) );
170 mainwp_add_translation( $mainwpTranslations, 'Any', esc_html__( 'Any', 'mainwp' ) );
171 mainwp_add_translation( $mainwpTranslations, 'HTTP error', esc_html__( 'HTTP error', 'mainwp' ) );
172 mainwp_add_translation( $mainwpTranslations, 'Error on your child WordPress', esc_html__( 'Error on your child WordPress', 'mainwp' ) );
173 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' ) );
174 mainwp_add_translation( $mainwpTranslations, 'Remove', esc_html__( 'Remove', 'mainwp' ) );
175 mainwp_add_translation( $mainwpTranslations, 'Please reconnect to Dropbox', esc_html__( 'Please reconnect to Dropbox', 'mainwp' ) );
176 mainwp_add_translation( $mainwpTranslations, 'Please wait', esc_html__( 'Please wait', 'mainwp' ) );
177 mainwp_add_translation( $mainwpTranslations, 'Upgrading all', esc_html__( 'Upgrading all', 'mainwp' ) );
178 mainwp_add_translation( $mainwpTranslations, 'Upgrading %1', esc_html__( 'Upgrading %1', 'mainwp' ) );
179 mainwp_add_translation( $mainwpTranslations, 'Updating your plan...', esc_html__( 'Updating your plan...', 'mainwp' ) );
180 mainwp_add_translation( $mainwpTranslations, 'Updated your plan', esc_html__( 'Updated your plan', 'mainwp' ) );
181 $mainwp_backup_before_upgrade_days = get_option( 'mainwp_backup_before_upgrade_days' );
182 if ( empty( $mainwp_backup_before_upgrade_days ) || ! ctype_digit( $mainwp_backup_before_upgrade_days ) ) {
183 $mainwp_backup_before_upgrade_days = 7;
184 }
185 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' ) ) );
186 mainwp_add_translation( $mainwpTranslations, 'Starting required backup(s).', esc_html__( 'Starting required backup(s).', 'mainwp' ) );
187 mainwp_add_translation( $mainwpTranslations, 'Required backup(s) complete', esc_html__( 'Required backup(s) complete', 'mainwp' ) );
188 mainwp_add_translation( $mainwpTranslations, 'Continue update anyway', esc_html__( 'Continue update anyway', 'mainwp' ) );
189 mainwp_add_translation( $mainwpTranslations, 'Continue update', esc_html__( 'Continue update', 'mainwp' ) );
190 mainwp_add_translation( $mainwpTranslations, 'Pause', esc_html__( 'Pause', 'mainwp' ) );
191 mainwp_add_translation( $mainwpTranslations, 'Resume', esc_html__( 'Resume', 'mainwp' ) );
192 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' ) );
193 mainwp_add_translation( $mainwpTranslations, 'Full backup required', esc_html__( 'Full backup required', 'mainwp' ) );
194 mainwp_add_translation( $mainwpTranslations, 'Checking backup settings', esc_html__( 'Checking backup settings', 'mainwp' ) );
195 mainwp_add_translation( $mainwpTranslations, 'Hide Shortcuts', esc_html__( 'Hide Shortcuts', 'mainwp' ) );
196 mainwp_add_translation( $mainwpTranslations, 'Show Shortcuts', esc_html__( 'Show Shortcuts', 'mainwp' ) );
197 mainwp_add_translation( $mainwpTranslations, 'Are you sure?', esc_html__( 'Are you sure?', 'mainwp' ) );
198 mainwp_add_translation( $mainwpTranslations, 'Bulk reconnect finished.', esc_html__( 'Bulk reconnect finished.', 'mainwp' ) );
199 mainwp_add_translation( $mainwpTranslations, 'Note Saved', esc_html__( 'Note Saved', 'mainwp' ) );
200 mainwp_add_translation( $mainwpTranslations, 'An error occured while saving your message', esc_html__( 'An error occured while saving your message', 'mainwp' ) );
201 mainwp_add_translation( $mainwpTranslations, 'Download from child site completed.', esc_html__( 'Download from child site completed.', 'mainwp' ) );
202 mainwp_add_translation( $mainwpTranslations, 'Please wait while we are saving your note', esc_html__( 'Please wait while we are saving your note', 'mainwp' ) );
203 mainwp_add_translation( $mainwpTranslations, 'Installation Successful', esc_html__( 'Installation Successful', 'mainwp' ) );
204 mainwp_add_translation( $mainwpTranslations, 'Upload to %1 (%2) successful.', esc_html__( 'Upload to %1 (%2) successful.', 'mainwp' ) );
205 mainwp_add_translation( $mainwpTranslations, 'Upload to %1 (%2) failed:', esc_html__( 'Upload to %1 (%2) failed:', 'mainwp' ) );
206 mainwp_add_translation( $mainwpTranslations, 'Updating Themes', esc_html__( 'Updating Themes', 'mainwp' ) );
207 mainwp_add_translation( $mainwpTranslations, 'Updating Plugins', esc_html__( 'Updating Plugins', 'mainwp' ) );
208 mainwp_add_translation( $mainwpTranslations, 'Updating WordPress', esc_html__( 'Updating WordPress', 'mainwp' ) );
209 mainwp_add_translation( $mainwpTranslations, 'updated', esc_html__( 'updated', 'mainwp' ) );
210 mainwp_add_translation( $mainwpTranslations, 'Updating', esc_html__( 'Updating', 'mainwp' ) );
211 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' ) );
212 mainwp_add_translation( $mainwpTranslations, 'The backup task was added successfully', esc_html__( 'The backup task was added successfully', 'mainwp' ) );
213 mainwp_add_translation( $mainwpTranslations, 'Bulk test connection finished', esc_html__( 'Bulk test connection finished', 'mainwp' ) );
214 /* translators: %1: Opening anchor tag, %2: Closing anchor tag, %3: HTTP status code number */
215 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' ) );
216 /* translators: %1: Opening anchor tag, %2: Closing anchor tag */
217 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' ) );
218 mainwp_add_translation( $mainwpTranslations, 'No ignored abandoned plugins', esc_html__( 'No ignored abandoned plugins', 'mainwp' ) );
219 mainwp_add_translation( $mainwpTranslations, 'Please upload plugins to install.', esc_html__( 'Please upload plugins to install.', 'mainwp' ) );
220 mainwp_add_translation( $mainwpTranslations, 'Please upload themes to install.', esc_html__( 'Please upload themes to install.', 'mainwp' ) );
221 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' ) );
222 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' ) );
223 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' ) );
224 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' ) );
225 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' ) );
226 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' ) );
227 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' ) );
228 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' ) );
229 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' ) );
230 mainwp_add_translation( $mainwpTranslations, 'is_activated_theme', esc_html__( '%1 could not be deleted. This theme is active theme.', 'mainwp' ) );
231 mainwp_add_translation( $mainwpTranslations, 'Change score changed. Click to review changes.', esc_html__( 'Change score changed. Click to review changes.', 'mainwp' ) );
232
233 return $mainwpTranslations;
234 }
235
236 /**
237 * Check if MainWP Extensions are Activated or not.
238 *
239 * @param mixed $plugin_slug Plugin Slug.
240 *
241 * @return string Activation warning message.
242 *
243 * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_indexed_extensions_infor()
244 */
245 public static function after_extensions_plugin_row( $plugin_slug ) {
246 $extensions = MainWP_Extensions_Handler::get_indexed_extensions_infor();
247 if ( ! isset( $extensions[ $plugin_slug ] ) ) {
248 return;
249 }
250
251 if ( ! isset( $extensions[ $plugin_slug ]['apiManager'] ) || ! $extensions[ $plugin_slug ]['apiManager'] ) {
252 return;
253 }
254
255 if ( isset( $extensions[ $plugin_slug ]['activated_key'] ) && 'Activated' === $extensions[ $plugin_slug ]['activated_key'] ) {
256 return;
257 }
258
259 $slug = basename( $plugin_slug, '.php' );
260
261 $activate_notices = get_user_option( 'mainwp_hide_activate_notices' );
262 if ( is_array( $activate_notices ) && isset( $activate_notices[ $slug ] ) ) {
263 return;
264 }
265 ?>
266 <style type="text/css">
267 tr[data-plugin="<?php echo esc_attr( $plugin_slug ); ?>"] {
268 box-shadow: none;
269 }
270 </style>
271 <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">
272 <?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>' ); ?>
273 <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>
274 </div></td></tr>
275 <?php
276 }
277
278 /**
279 * MainWP Version 4 update Notice.
280 *
281 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
282 */
283 public static function mainwp_4_update_notice() {
284 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_4' ) ) {
285 ?>
286 <div class="ui icon message yellow">
287 <i class="exclamation circle icon"></i>
288 <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. ?>
289 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_4"></i>
290 </div>
291 <?php
292 }
293 }
294
295 /**
296 * MainWP Version ver 5 update Notice.
297 *
298 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
299 */
300 public static function mainwp_ver5_update_notice() {
301 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_version5' ) ) {
302 ?>
303 <div class="ui modal" id="mainwp-v5-update-notice-modal">
304 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_version5"></i>
305 <div class="header">
306 <?php echo esc_html__( 'MainWP 5.0 Update Notice', 'mainwp' ); ?>
307 </div>
308 <div class="content">
309 <h3 class="ui header">
310 <i class="sync alternate icon"></i>
311 <div class="content">
312 <?php echo esc_html__( 'Hard Refresh Required', 'mainwp' ); ?>
313
314 </div>
315 </h3>
316 <div class="ui hidden divider"></div>
317 <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>
318 <br/>
319 <div><?php echo esc_html__( 'This step is crucial for loading the latest updates effectively.', 'mainwp' ); ?></div>
320 <div class="ui list">
321 <div class="item"><i class="windows icon"></i> <?php echo esc_html__( 'Windows users: Press `Ctrl + F5`', 'mainwp' ); ?></div>
322 <div class="item"><i class="apple icon"></i> <?php echo esc_html__( 'Mac users: Press `Command + R`', 'mainwp' ); ?></div>
323 <div class="item"><i class="linux icon"></i> <?php echo esc_html__( 'Linux users: Press `F5`', 'mainwp' ); ?></div>
324 </div>
325
326 <div class="ui divider"></div>
327
328 <h3 class="ui header">
329 <i class="linkify icon"></i>
330 <div class="content">
331 <?php echo esc_html__( 'Extensions License Reactivation Required', 'mainwp' ); ?>
332
333 </div>
334 </h3>
335 <div class="ui hidden divider"></div>
336 <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>
337 <br/>
338 <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>
339
340 <div class="ui divider"></div>
341
342 <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>
343 <div class="ui hidden divider"></div>
344 <div><?php echo esc_html__( 'Thank you for using MainWP!', 'mainwp' ); ?></div>
345 </div>
346 </div>
347 <script type="text/javascript">
348 jQuery( document ).ready( function() {
349 jQuery( '#mainwp-v5-update-notice-modal' ).modal({
350 onHidden: function () {
351 let notice_id = jQuery( '#mainwp-v5-update-notice-modal' ).find('.mainwp-notice-dismiss').attr('notice-id');
352 let data = {
353 action: 'mainwp_notice_status_update'
354 };
355 data['notice_id'] = notice_id;
356 jQuery.post(ajaxurl, mainwp_secure_data(data), function () { });
357 },
358 }).modal('show');
359 });
360 </script>
361 <?php
362 }
363 }
364
365 /**
366 * MainWP Version ver 5 update Notice.
367 *
368 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
369 */
370 public static function mainwp_ver502_update_notice() {
371 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_version502' ) ) {
372 ?>
373 <div class="ui modal" id="mainwp-v502-update-notice-modal">
374 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_version502"></i>
375 <div class="header">
376 <?php echo esc_html__( 'MainWP 5.0.2 Update Notice', 'mainwp' ); ?>
377 </div>
378 <div class="content">
379 <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>
380 <br/>
381 <div><?php echo esc_html__( 'This step is crucial for loading the latest updates effectively.', 'mainwp' ); ?></div>
382 <div class="ui list">
383 <div class="item"><i class="windows icon"></i> <?php echo esc_html__( 'Windows users: Press `Ctrl + F5`', 'mainwp' ); ?></div>
384 <div class="item"><i class="apple icon"></i> <?php echo esc_html__( 'Mac users: Press `Command + R`', 'mainwp' ); ?></div>
385 <div class="item"><i class="linux icon"></i> <?php echo esc_html__( 'Linux users: Press `F5`', 'mainwp' ); ?></div>
386 </div>
387 </div>
388 </div>
389 <script type="text/javascript">
390 jQuery( document ).ready( function() {
391 jQuery( '#mainwp-v502-update-notice-modal' ).modal({
392 onHidden: function () {
393 let notice_id = jQuery( '#mainwp-v502-update-notice-modal' ).find('.mainwp-notice-dismiss').attr('notice-id');
394 let data = {
395 action: 'mainwp_notice_status_update'
396 };
397 data['notice_id'] = notice_id;
398 jQuery.post(ajaxurl, mainwp_secure_data(data), function () { });
399 },
400 }).modal('show');
401 });
402 </script>
403 <?php
404 }
405 }
406
407 /**
408 * MainWP Version ver 6.1 update Notice.
409 *
410 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
411 */
412 public static function mainwp_ver61_update_notice() {
413 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_version61' ) && MainWP_DB::instance()->get_websites_count() > 0 ) {
414 ?>
415 <div class="ui attention message">
416 <div class="header"><?php esc_html_e( 'Important Rollback Notice', 'mainwp' ); ?></div>
417 <div>
418 <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>
419 <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>
420 <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>
421 </div>
422 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_version61"></i>
423 </div>
424 <?php
425 }
426 }
427
428 /**
429 * MainWP Version ver 5 update Notice.
430 *
431 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
432 */
433 public static function mainwp_ver5_update_clear_cache_notice() {
434 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_ver5_clear_cache' ) ) {
435 ?>
436 <div class="ui message info">
437 <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>
438 <div class="ui list">
439 <div class="item"><?php echo esc_html__( 'Windows users: Press `Ctrl + F5`', 'mainwp' ); ?></div>
440 <div class="item"><?php echo esc_html__( 'Mac users: Press `Command + R`', 'mainwp' ); ?></div>
441 <div class="item"><?php echo esc_html__( 'Linux users: Press `F5`', 'mainwp' ); ?></div>
442 </div>
443 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_ver5_clear_cache"></i>
444 </div>
445 <?php
446 }
447 }
448
449
450 /**
451 * Render Administration Notice.
452 *
453 * @uses \MainWP\Dashboard\MainWP_System::is_mainwp_pages()
454 * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::check_auto_update_plugin()
455 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_openssl_config_warning()
456 */
457 public static function admin_notices() {
458
459 static::mainwp_tmpfile_check();
460
461 static::render_notice_config_warning();
462
463 static::render_notice_multi_sites();
464
465 static::render_wp_mail_warning();
466
467 static::render_consumer_secret_migration_failed_notice();
468
469 static::render_secure_priv_key_connection();
470
471 static::render_notice_php_version8();
472
473 static::render_notice_trust_update();
474
475 static::render_mainwp_themes_deprecation_notice();
476
477 static::render_tours_notice();
478
479 static::check_rating_notice();
480
481 static::render_browser_extensions_notice();
482
483 }
484
485 /**
486 * Render MainWP themes deprecation notice.
487 *
488 * @uses \MainWP\Dashboard\MainWP_Settings::get_instance()
489 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
490 */
491 public static function render_mainwp_themes_deprecation_notice() {
492 $selected_theme = MainWP_Settings::get_instance()->get_selected_theme();
493 $legacy_themes = array( 'dark', 'wpadmin', 'minimalistic', 'classic', 'default-2024' );
494
495 if ( in_array( $selected_theme, $legacy_themes, true ) && MainWP_Utility::show_mainwp_message( 'notice', 'mainwp_themes_deprecation_notice' ) ) {
496 $message_class = 'default-2024' === $selected_theme ? 'attention' : 'yellow';
497 ?>
498 <div class="ui <?php echo esc_attr( $message_class ); ?> message">
499 <div class="header"><?php esc_html_e( 'MainWP Dashboard Theme Support Notice', 'mainwp' ); ?></div>
500 <div>
501 <?php
502 /* translators: 1: Opening anchor tag, 2: Closing anchor tag */
503 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>' );
504 ?>
505 </div>
506 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp_themes_deprecation_notice"></i>
507 </div>
508 <?php
509 }
510 }
511
512 /**
513 * Method mainwp_tmpfile_check()
514 *
515 * Checks if the `tmpfile()` PHP function is disabled.
516 */
517 public static function mainwp_tmpfile_check() {
518 if ( MainWP_Demo_Handle::is_instawp_site() ) {
519 return;
520 }
521 if ( ! static::is_tmpfile_enable() && MainWP_Utility::show_mainwp_message( 'notice', 'tmpfile_notice' ) ) {
522 ?>
523 <div class="ui red message">
524 <div class="header"><?php esc_html_e( 'Server configuration required (tmpfile disabled)', 'mainwp' ); ?></div>
525 <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>
526 <i class="close icon mainwp-notice-dismiss" notice-id="tmpfile_notice"></i>
527 </div>
528 <?php
529 }
530 }
531
532 /**
533 * Method is_tmpfile_enable()
534 *
535 * Checks if the `tmpfile()` PHP function is enable.
536 */
537 public static function is_tmpfile_enable() {
538 if ( ! function_exists( '\tmpfile' ) ) {
539 return false;
540 }
541 $disabled_functions = ini_get( 'disable_functions' );
542 return '' !== $disabled_functions && false !== stripos( $disabled_functions, 'tmpfile' ) ? false : true;
543 }
544
545 /**
546 * Renders Browsers extensions notice.
547 *
548 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
549 */
550 public static function render_browser_extensions_notice() {
551 if ( MainWP_DB::instance()->get_websites_count() > 4 && MainWP_Utility::show_mainwp_message( 'notice', 'mainwp_browser_extensions_notice' ) ) {
552 ?>
553 <div class="ui info message">
554 <div class="header"><?php esc_html_e( 'Track Updates and Non-MainWP Changes from Your Browser!', 'mainwp' ); ?></div>
555 <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>
556 <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>
557 <br/>
558 <div>
559 <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>
560 <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>
561 </div>
562 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp_browser_extensions_notice"></i>
563 </div>
564 <?php
565 }
566 }
567
568 /**
569 * Renders Browsers extensions notice.
570 *
571 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
572 */
573 public static function render_secure_priv_key_connection() {
574 if ( MainWP_DB::instance()->get_websites_count() > 0 && ! static::check_keys_encrypted() && MainWP_Utility::show_mainwp_message( 'notice', 'mainwp_secure_priv_key_notice' ) ) {
575 ?>
576 <div class="ui attention message">
577 <div class="header"><?php esc_html_e( 'New Security Feature: OpenSSL Key Encryption', 'mainwp' ); ?></div>
578 <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>
579 <p><button class="ui green mini button" id="increase-connection-security-btn"><?php echo esc_html__( 'Encrypt Keys Now', 'mainwp' ); ?></button></p>
580 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp_secure_priv_key_notice"></i>
581 </div>
582 <?php
583 }
584 }
585
586 /**
587 * Method check_keys_encrypted().
588 *
589 * @return bool Keys encrypted or not.
590 */
591 public static function check_keys_encrypted() {
592 if ( get_option( 'mainwp_keys_is_encrypted' ) ) {
593 return true;
594 }
595 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, true ) );
596 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
597 // try to decrypt priv key.
598 $de_privkey = MainWP_Encrypt_Data_Lib::instance()->decrypt_privkey( base64_decode( $website->privkey ), $website->id ); // phpcs:ignore -- NOSONAR - base64_encode trust.
599 if ( ! empty( $de_privkey ) ) {
600 update_option( 'mainwp_keys_is_encrypted', 1 );
601 return true;
602 }
603 }
604 return false;
605 }
606
607
608 /**
609 * Renders wp_mail warning.
610 */
611 public static function render_wp_mail_warning() {
612 $mail_failed = get_option( 'mainwp_notice_wp_mail_failed' );
613 if ( 'yes' === $mail_failed ) {
614 ?>
615 <div class="ui yellow message">
616 <div class="header"><?php esc_html_e( 'Email sending failed (wp_mail)', 'mainwp' ); ?></div>
617 <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>
618 <i class="close icon mainwp-notice-dismiss" notice-id="mail_failed"></i>
619 </div>
620 <?php
621 }
622 }
623
624 /**
625 * Renders a notice when the consumer_secret schema migration did not complete.
626 *
627 * The migration in MainWP_Install::update_optimize_indexes_55() widens
628 * wp_mainwp_api_keys.consumer_secret to varchar(255) so that hashed
629 * secrets fit. If the ALTER TABLE silently fails on the host, modern
630 * bcrypt hashes get truncated and authentication breaks for any newly
631 * created API key. The flag option is set when the post-migration
632 * SHOW COLUMNS check finds the column still narrower than expected.
633 */
634 public static function render_consumer_secret_migration_failed_notice() {
635 $failed_at = get_option( 'mainwp_notice_consumer_secret_migration_failed' );
636 if ( empty( $failed_at ) ) {
637 return;
638 }
639 ?>
640 <div class="ui red message">
641 <div class="header"><?php esc_html_e( 'REST API keys table upgrade did not complete', 'mainwp' ); ?></div>
642 <div>
643 <?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' ); ?>
644 </div>
645 </div>
646 <?php
647 }
648
649 /**
650 * Renders PHP 8.0 Version Notice.
651 *
652 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
653 */
654 public static function render_notice_php_version8() {
655 $phpver = phpversion();
656 if ( version_compare( $phpver, '8.0', '<' ) ) {
657 $last_hidden = (int) get_user_option( 'lasttime_hidden_phpver_8_0' );
658 if ( time() > $last_hidden + 30 * DAY_IN_SECONDS || MainWP_Utility::show_mainwp_message( 'notice', 'phpver_8_0' ) ) {
659 ?>
660 <div class="ui attention message">
661 <div class="header"><?php esc_html_e( 'Upcoming PHP requirement (Dashboard)', 'mainwp' ); ?></div>
662 <?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' ); ?>
663 <?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>' ); ?>
664 <br/><br/>
665 <strong><?php esc_html_e( 'This change affects only your MainWP Dashboard site, not your connected child sites.', 'mainwp' ); ?></strong>
666 <i class="close icon mainwp-notice-dismiss" notice-id="phpver_8_0"></i>
667 </div>
668 <?php
669 }
670 }
671 }
672
673
674 /**
675 * Renders Guided Tours Notice.
676 *
677 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
678 */
679 public static function render_tours_notice() {
680 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' ) ) {
681 ?>
682 <div class="ui info message">
683 <div class="header"><?php esc_html_e( 'Enable guided tours?', 'mainwp' ); ?></div>
684 <div><?php esc_html_e( 'Guided tours highlight essential features on each Dashboard page. You can turn them off anytime.', 'mainwp' ); ?></div>
685 <div class="ui hidden divider"></div>
686 <div class="ui form">
687 <div class="field">
688 <div class="ui toggle checkbox">
689 <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"' : ''; ?>>
690 <label for="mainwp-select-guided-tours-option"><?php esc_html_e( 'Select to enable the MainWP Guided Tours.', 'mainwp' ); ?></label>
691 </div>
692 </div>
693 </div>
694 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp_guided_tours_notice"></i>
695 </div>
696 <?php
697 }
698 }
699
700 /**
701 * Renders OpenSSL Error message.
702 *
703 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
704 */
705 public static function render_notice_config_warning() {
706 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
707 ?>
708 <div class="ui yellow message">
709 <div class="header"><?php esc_html_e( 'OpenSSL configuration required', 'mainwp' ); ?></div>
710 <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>
711 <i class="close icon mainwp-notice-dismiss" notice-id="ssl_warn"></i>
712 </div>
713 <?php
714 }
715 }
716
717 /** Renders WP Multisite Error Message. */
718 public static function render_notice_multi_sites() {
719 $current_options = get_option( 'mainwp_showhide_events_notice' );
720 if ( ! is_array( $current_options ) ) {
721 $current_options = array();
722 }
723
724 if ( is_multisite() && ( ! isset( $current_options['hide_multi_site_notice'] ) || empty( $current_options['hide_multi_site_notice'] ) ) ) {
725 ?>
726 <div class="ui yellow message">
727 <div class="header"><?php esc_html_e( 'Multisite detected (limited support)', 'mainwp' ); ?></div>
728 <?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' ); ?>
729 <i class="close icon mainwp-notice-dismiss" notice-id="multi_site"></i>
730 </div>
731 <?php
732 }
733 }
734
735 /**
736 * Renders MainWP Review Request.
737 *
738 * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_extensions()
739 */
740 public static function check_rating_notice() { // phpcs:ignore -- NOSONAR - complex.
741 $current_options = get_option( 'mainwp_showhide_events_notice' );
742 if ( ! is_array( $current_options ) ) {
743 $current_options = array();
744 }
745
746 $display_request1 = false;
747 $display_request2 = false;
748
749 if ( isset( $current_options['request_reviews1'] ) ) {
750 if ( 'forever' === $current_options['request_reviews1'] ) {
751 $display_request1 = false;
752 } else {
753 $days = intval( $current_options['request_reviews1'] );
754 $start_time = $current_options['request_reviews1_starttime'];
755 $display_request1 = ( ( time() - $start_time ) > $days * 24 * 3600 ) ? true : false;
756 }
757 } else {
758 $current_options['request_reviews1'] = 30;
759 $current_options['request_reviews1_starttime'] = time();
760 update_option( 'mainwp_showhide_events_notice', $current_options );
761 }
762
763 $currentExtensions = MainWP_Extensions_Handler::get_extensions();
764 $has_many_addons = is_array( $currentExtensions ) && count( $currentExtensions ) > 10;
765
766 if ( $display_request1 && $has_many_addons ) {
767 static::render_review_mainwp_notice( true );
768 } elseif ( $display_request1 ) {
769 static::render_review_mainwp_notice( false );
770 }
771 }
772
773 /**
774 * Renders MainWP review request notice.
775 *
776 * Displays a dismissible notice encouraging users to leave a review on WordPress.org.
777 * Message content varies based on whether user has extensions installed.
778 *
779 * @since 6.0.0
780 *
781 * @param bool $addons Whether user has add-ons/extensions installed. Default false.
782 * @return void
783 */
784 public static function render_review_mainwp_notice( $addons = false ) {
785 ?>
786 <div class="ui segment">
787 <div class="ui icon message">
788 <i class="yellow star icon"></i>
789 <div class="content">
790 <div class="header"><?php esc_html_e( 'Enjoying MainWP?', 'mainwp' ); ?></div>
791 <div>
792 <?php if ( $addons ) : ?>
793 <?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' ); ?>
794 <?php else : ?>
795 <?php esc_html_e( 'You\'ve been using MainWP for a while.', 'mainwp' ); ?>
796 <?php endif; ?>
797 </div>
798 <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>
799 </div>
800 <div class="" style="float:right">
801 <div class="ui buttons">
802 <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>
803 <div class="ui floating dropdown icon green mini button" style="opacity:0.85">
804 <i class="dropdown icon"></i>
805 <div class="menu">
806 <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>
807 <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>
808 </div>
809 </div>
810 </div>
811 <a href="" class="ui mini basic grey button mainwp-events-notice-dismiss" notice="request_reviews1"><?php esc_html_e( 'Remind me later', 'mainwp' ); ?></a>
812 </div>
813 <i class="close icon mainwp-events-notice-dismiss" notice="request_reviews1_forever"></i>
814 </div>
815 </div>
816 <?php
817 }
818
819 /**
820 * Renders MainWP Dashboard & Child Plugin auto update Alert.
821 */
822 public static function render_notice_trust_update() {
823 $current_options = get_option( 'mainwp_showhide_events_notice' );
824 if ( ! is_array( $current_options ) ) {
825 $current_options = array();
826 }
827
828 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' ) ) {
829 ?>
830 <div class="ui info message">
831 <div class="header"><?php esc_html_e( 'Keep MainWP Child up to date', 'mainwp' ); ?></div>
832 <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>
833 <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>
834 <i class="close icon mainwp-events-notice-dismiss" notice="trust_child"></i>
835 </div>
836 <?php
837 }
838 }
839
840
841
842 /** Renders Send Mail Function may have failed error. */
843 public static function wp_admin_notices() {
844
845 /**
846 * Current pagenow.
847 *
848 * @global string
849 */
850 global $pagenow;
851
852 if ( 'plugins.php' !== $pagenow ) {
853 return;
854 }
855
856 $deactivated_exts = get_transient( 'mainwp_transient_deactivated_incomtible_exts' );
857 if ( $deactivated_exts && is_array( $deactivated_exts ) && ! empty( $deactivated_exts ) ) {
858 ?>
859 <div class='notice notice-error my-dismiss-notice is-dismissible'>
860 <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>
861 </div>
862 <?php
863 }
864 }
865
866 /**
867 * Method admin_footer()
868 *
869 * Renders admin footer.
870 */
871 public static function admin_footer() {
872 $disabled_confirm = get_option( 'mainwp_disable_update_confirmations', 0 );
873 ?>
874 <input type="hidden" id="mainwp-disable-update-confirmations" value="<?php echo intval( $disabled_confirm ); ?>">
875
876 <script type="text/javascript">
877 jQuery( document ).ready(
878 function ()
879 {
880 jQuery( '#adminmenu #collapse-menu' ).hide();
881 }
882 );
883 </script>
884 <?php
885 /**
886 * Filter: mainwp_open_hide_referrer
887 *
888 * Filters whether the MainWP should hide referrer when going to child site.
889 *
890 * @since Unknown
891 */
892 $hide_ref = apply_filters( 'mainwp_open_hide_referrer', false );
893 if ( $hide_ref ) {
894 ?>
895 <script type="text/javascript">
896 jQuery( document ).on( 'click', 'a.mainwp-may-hide-referrer', function ( e ) {
897 e.preventDefault();
898 mainwp_open_hide_referrer( e.target.href );
899 } );
900
901 function mainwp_open_hide_referrer( url ) {
902 let ran = Math.floor( Math.random() * 100 ) + 1;
903 let site = window.open( "", "mainwp_hide_referrer_" + ran );
904 let meta = site.document.createElement( 'meta' );
905 meta.name = "referrer";
906 meta.content = "no-referrer";
907 site.document.getElementsByTagName( 'head' )[0].appendChild( meta );
908 site.document.open();
909 site.document.writeln( '<script type="text/javascript">window.location = "' + url + '";<\/script>' );
910 site.document.close();
911 }
912 </script>
913 <?php
914 }
915 }
916
917 /**
918 * Admin print styles.
919 *
920 * @uses \MainWP\Dashboard\MainWP_System::is_mainwp_pages()
921 */
922 public static function admin_print_styles() {
923 ?>
924 <style>
925 <?php
926 if ( MainWP_System::is_mainwp_pages() ) {
927 ?>
928 #wpbody-content > div.update-nag,
929 #wpbody-content > div.updated {
930 margin-left: 190px;
931 }
932 html.wp-toolbar{
933 padding-top: 0 !important;
934 }
935 <?php
936 }
937 ?>
938 .mainwp-checkbox:before {
939 content: '<?php esc_html_e( 'YES', 'mainwp' ); ?>';
940 }
941 .mainwp-checkbox:after {
942 content: '<?php esc_html_e( 'NO', 'mainwp' ); ?>';
943 }
944 </style>
945 <?php
946 }
947
948 /**
949 * Productions site warning.
950 *
951 * Renders the warning if the production site is detected.
952 *
953 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count()
954 */
955 public static function mainwp_warning_notice() {
956 if ( 'yes' === get_option( 'mainwp_installation_warning_hide_the_notice' ) ) {
957 return;
958 }
959 if ( MainWP_DB::instance()->get_websites_count() > 0 ) {
960 return;
961 } else {
962 $plugins = get_plugins();
963 if ( ! is_array( $plugins ) || count( $plugins ) <= 4 ) {
964 return;
965 }
966 }
967 ?>
968 <div class="ui blue message">
969 <h4><?php esc_html_e( 'This appears to be a production site', 'mainwp' ); ?></h4>
970 <?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>")' ); ?>
971 <br /><br />
972 <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>
973 </div>
974 <?php
975 }
976
977 /** Render Admin Header */
978 public static function admin_head() {
979 ?>
980 <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>
981 <?php
982 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
983 static::mainwp_usetiful_tours();
984 }
985 }
986
987 /**
988 * Render usetiful tours.
989 */
990 public static function mainwp_usetiful_tours() {
991 echo "
992 <script>
993 (function (w, d, s) {
994 console.log('init usetifulScript');
995 let a = d.getElementsByTagName('head')[0];
996 let r = d.createElement('script');
997 r.async = 1;
998 r.src = s;
999 r.setAttribute('id', 'usetifulScript');
1000 r.dataset.token = '480fa17b0507a1c60abba94bfdadd0a7';
1001 a.appendChild(r);
1002 })(window, document, 'https://www.usetiful.com/dist/usetiful.js');</script>
1003 ";
1004 }
1005
1006 /**
1007 * MainWP Admin body CSS class attributes.
1008 *
1009 * @param mixed $class_string MainWP CSS Class attributes.
1010 *
1011 * @return string $class_string The CSS attributes to add to the page.
1012 *
1013 * @uses \MainWP\Dashboard\MainWP_System::is_mainwp_pages()
1014 */
1015 public static function admin_body_class( $class_string ) { // phpcs:ignore -- NOSONAR - complex.
1016 if ( MainWP_System::is_mainwp_pages() ) {
1017 $class_string .= ' mainwp-ui mainwp-ui-page ';
1018 $class_string .= ' mainwp-ui-leftmenu ';
1019
1020 $selected_theme = MainWP_Settings::get_instance()->get_selected_theme();
1021 if ( ! empty( $selected_theme ) ) {
1022 $class_string .= ' mainwp-custom-theme ';
1023 }
1024
1025 if ( ! empty( $selected_theme ) && is_string( $selected_theme ) ) {
1026 $class_string .= ' mainwp-' . $selected_theme . '-theme ';
1027 } else {
1028 $class_string .= ' mainwp-classic-theme ';
1029 }
1030
1031 $siteViewMode = MainWP_Utility::get_siteview_mode();
1032 if ( 'grid' === $siteViewMode ) {
1033 $class_string .= ' mainwp-sites-grid-view ';
1034 } else {
1035 $class_string .= ' mainwp-sites-table-view ';
1036 }
1037
1038 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1039 if ( isset( $_GET['page'] ) && 'managesites' === $_GET['page'] && isset( $_GET['dashboard'] ) && ! empty( $_GET['dashboard'] ) ) {
1040 $class_string .= ' mainwp-individual-site-overview ';
1041 }
1042
1043 if ( isset( $_GET['page'] ) && 'ManageClients' === $_GET['page'] && isset( $_GET['client_id'] ) && ! empty( $_GET['client_id'] ) ) {
1044 $class_string .= ' mainwp-individual-client-overview ';
1045 }
1046 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'] || 'MainWPTools' === $_GET['page'] || 'SettingsInsights' === $_GET['page'] || 'SettingsApiBackups' === $_GET['page'] || 'MonitoringSettings' === $_GET['page'] ) ) {
1047 $class_string .= ' mainwp-individual-site-view ';
1048 }
1049 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'] ) ) ) ) {
1050 $class_string .= ' mainwp-individual-site-view ';
1051 }
1052 // phpcs:enable
1053 $class_string = apply_filters( 'mainwp_page_admin_body_class', $class_string );
1054 }
1055 return $class_string;
1056 }
1057
1058 /**
1059 * Method render_footer_content()
1060 *
1061 * Render footer content.
1062 *
1063 * @param mixed $websites The websites object.
1064 * @param int $current_wpid The current website id.
1065 *
1066 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1067 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
1068 * @uses \MainWP\Dashboard\MainWP_Utility::get_nice_url()
1069 */
1070 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.
1071 if ( is_array( $websites ) ) {
1072 $count = count( $websites );
1073 for ( $i = 0; $i < $count; $i++ ) {
1074 $website = $websites[ $i ];
1075 echo '<input type="hidden" name="dashboard_wp_ids[]" class="dashboard_wp_id" error-status="' . ( empty( $website->sync_errors ) ? 0 : 1 ) . '" value="' . intval( $website->id ) . '" />';
1076 }
1077 } elseif ( false !== $websites ) {
1078 while ( $website = MainWP_DB::fetch_object( $websites ) ) {
1079 echo '<input type="hidden" name="dashboard_wp_ids[]" class="dashboard_wp_id" error-status="' . ( empty( $website->sync_errors ) ? 0 : 1 ) . '" value="' . intval( $website->id ) . '" />';
1080 }
1081 }
1082 /**
1083 * Action: mainwp_admin_footer
1084 *
1085 * Fires at the bottom of MainWP content.
1086 *
1087 * @since Unknown
1088 */
1089 do_action( 'mainwp_admin_footer' );
1090 MainWP_UI::render_select_mainwp_themes_modal();
1091 MainWP_UI::render_install_extensions_promo_modal();
1092 ?>
1093 <div class="ui modal" id="mainwp-sync-sites-modal" current-wpid="<?php echo intval( $current_wpid ); ?>">
1094 <i class="mainwp-modal-close close icon"></i>
1095 <div class="header"><?php esc_html_e( 'Data Synchronization', 'mainwp' ); ?></div>
1096 <div class="ui green progress mainwp-modal-progress">
1097 <div class="bar"><div class="progress"></div></div>
1098 <div class="label"></div>
1099 </div>
1100 <div class="scrolling content mainwp-modal-content">
1101 <div class="ui middle aligned divided list" id="sync-sites-status">
1102 <?php
1103 if ( is_array( $websites ) ) {
1104 $count = count( $websites );
1105 for ( $i = 0; $i < $count; $i++ ) {
1106 $site_name = $website->name;
1107 $website = $websites[ $i ];
1108 $is_sync_err = ( '' !== $website->sync_errors ) ? true : false;
1109 ?>
1110 <div class="item <?php echo $is_sync_err ? 'disconnected-site' : ''; ?>">
1111 <div class="right floated content">
1112 <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>
1113 </div>
1114 <div class="content">
1115 <?php echo esc_html( $site_name ); ?>
1116 <?php do_action( 'mainwp_sync_popup_content', $website ); ?>
1117 </div>
1118 </div>
1119 <?php
1120 }
1121 } else {
1122 MainWP_DB::data_seek( $websites, 0 );
1123 while ( $website = MainWP_DB::fetch_object( $websites ) ) {
1124 $site_name = $website->name;
1125 $is_sync_err = ( '' !== $website->sync_errors ) ? true : false;
1126 ?>
1127 <div class="item <?php echo $is_sync_err ? 'disconnected-site' : ''; ?>">
1128 <div class="right floated content">
1129 <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>
1130 </div>
1131 <div class="content">
1132 <?php echo esc_html( $site_name ); ?>
1133 <?php do_action( 'mainwp_sync_popup_content', $website ); ?>
1134 </div>
1135 </div>
1136 <?php
1137 }
1138 }
1139 ?>
1140 </div>
1141 </div>
1142 </div>
1143 <input type="hidden" id="sync_selected_site_ids" value="" />
1144 <div class="ui tiny modal" id="mainwp-modal-confirm-select">
1145 <i class="close icon"></i>
1146 <div class="header"><?php esc_html_e( 'Confirmation', 'mainwp' ); ?></div>
1147 <div class="content">
1148 <div class="content-massage"></div>
1149 </div>
1150 <div class="actions">
1151 </div>
1152 </div>
1153 <?php
1154 static::render_comfirm_modal();
1155 }
1156
1157 /**
1158 * Method render_comfirm_modal()
1159 *
1160 * Render comfirm modal box.
1161 */
1162 public static function render_comfirm_modal() {
1163 ?>
1164 <div class="ui tiny modal" id="mainwp-modal-confirm">
1165 <i class="close icon"></i>
1166 <div class="header"><?php esc_html_e( 'Confirmation', 'mainwp' ); ?></div>
1167 <div class="scrolling content">
1168 <div class="content-massage"></div>
1169 <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>
1170 <div class="ui form hidden" id="mainwp-confirm-form" style="display:none;">
1171 <div class="ui divider"></div>
1172 <div class="field">
1173 <label></label>
1174 <input type="text" id="mainwp-confirm-input" name="mainwp-confirm-input">
1175 </div>
1176 </div>
1177 </div>
1178 <div class="actions">
1179 <div class="ui two columns grid">
1180 <div class="ui left aligned column">
1181 </div>
1182 <div class="ui right aligned column">
1183 <div class="ui green positive button"><?php esc_html_e( 'Yes, proceed!', 'mainwp' ); ?></div>
1184 </div>
1185 </div>
1186 </div>
1187 </div>
1188 <?php
1189 }
1190
1191 /**
1192 * Method get_plugins_install_check()
1193 *
1194 * Get plugins for install checking.
1195 */
1196 public static function get_plugins_install_check() {
1197 $plugins = array(
1198 array(
1199 'page' => 'Extensions-Mainwp-Pro-Reports-Extension',
1200 'slug' => 'mainwp-child-reports/mainwp-child-reports.php',
1201 'name' => 'MainWP Child Reports',
1202 ),
1203 array(
1204 'page' => 'Extensions-Mainwp-Client-Reports-Extension',
1205 'slug' => 'mainwp-child-reports/mainwp-child-reports.php',
1206 'name' => 'MainWP Child Reports',
1207 ),
1208 array(
1209 'page' => 'Extensions-Mainwp-Backwpup-Extension',
1210 'slug' => 'backwpup/backwpup.php',
1211 'name' => 'BackWPup',
1212 ),
1213 array(
1214 'page' => 'Extensions-Mainwp-Ithemes-Security-Extension',
1215 'slug' => 'better-wp-security/better-wp-security.php',
1216 'slug_pro' => 'ithemes-security-pro/ithemes-security-pro.php',
1217 'name' => 'Solid Security Integration',
1218 ),
1219 array(
1220 'page' => 'Extensions-Mainwp-Updraftplus-Extension',
1221 'slug' => 'updraftplus/updraftplus.php',
1222 'name' => 'UpdraftPlus',
1223 ),
1224 array(
1225 'page' => 'Extensions-Mainwp-Wordfence-Extension',
1226 'slug' => 'wordfence/wordfence.php',
1227 'name' => 'Wordfence',
1228 ),
1229 array(
1230 'page' => 'Extensions-Wordpress-Seo-Extension',
1231 'slug' => 'wordpress-seo/wp-seo.php',
1232 'name' => 'Yoast SEO',
1233 ),
1234 array(
1235 'page' => 'Extensions-Mainwp-Jetpack-Protect-Extension',
1236 'slug' => 'jetpack-protect/jetpack-protect.php',
1237 'name' => 'Jetpack Protect',
1238 ),
1239 array(
1240 'page' => 'Extensions-Mainwp-Jetpack-Scan-Extension',
1241 'slug' => 'jetpack-protect/jetpack-protect.php', // tweaked: to requires install the JP protect plugin.
1242 'slug_pro' => 'jetpack/jetpack.php',
1243 'name' => 'Jetpack Protect',
1244 ),
1245 );
1246 return apply_filters( 'mainwp_plugins_install_checks', $plugins );
1247 }
1248
1249 /**
1250 * Render plugins install check modal.
1251 * for the exntesion overview page with the missing install plugin only.
1252 */
1253 public static function render_plugins_install_check() { // phpcs:ignore -- NOSONAR - complex function.
1254
1255 $plugins_to_checks = static::get_plugins_install_check();
1256
1257 $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1258
1259 $plugin_check = MainWP_Utility::get_sub_array_having( $plugins_to_checks, 'page', $page );
1260
1261 if ( ! empty( $plugin_check ) ) {
1262 $plugin_check = current( $plugin_check );
1263 }
1264
1265 if ( empty( $plugin_check ) ) {
1266 return;
1267 }
1268
1269 // if is not overview extension page return.
1270 if ( isset( $_GET['tab'] ) && 'overview' !== $_GET['tab'] && 'dashboard' !== $_GET['tab'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1271 return;
1272 }
1273
1274 $plugin_slug = isset( $plugin_check['slug'] ) ? $plugin_check['slug'] : '';
1275 $slug_pro = isset( $plugin_check['slug_pro'] ) ? $plugin_check['slug_pro'] : '';
1276 $plugin_name = isset( $plugin_check['name'] ) ? $plugin_check['name'] : '';
1277
1278 if ( empty( $plugin_slug ) || empty( $plugin_name ) ) {
1279 return;
1280 }
1281
1282 $check_slug = 'install_check_' . sanitize_text_field( wp_unslash( dirname( $plugin_slug ) ) );
1283 $check_hidetime = MainWP_Utility::get_hide_notice_status( $check_slug );
1284
1285 if ( $check_hidetime && time() < $check_hidetime + 30 * DAY_IN_SECONDS ) {
1286 return;
1287 }
1288
1289 $wpsite_fields = array( 'id', 'name', 'url', 'plugins' );
1290 $sync_fields = array( 'sync_errors', 'totalsize' );
1291 $websites = MainWP_DB::instance()->query(
1292 MainWP_DB::instance()->get_sql_websites_for_current_user_by_params(
1293 array(
1294 'select_wp_fields' => $wpsite_fields,
1295 'select_sync_fields' => $sync_fields,
1296 )
1297 )
1298 );
1299
1300 if ( empty( $websites ) ) {
1301 return;
1302 }
1303
1304 $missing_installed = array();
1305
1306 while ( $websites && $website = MainWP_DB::fetch_object( $websites ) ) {
1307 $site_name = $website->name;
1308 if ( '' !== $website->sync_errors ) {
1309 continue;
1310 }
1311 $not_found = true;
1312 if ( '' !== $website->plugins ) {
1313 $plugins = json_decode( $website->plugins, 1 );
1314 if ( is_array( $plugins ) && ! empty( $plugins ) ) {
1315 foreach ( $plugins as $plugin ) {
1316 if ( isset( $plugin['slug'] ) && ( $plugin_slug === $plugin['slug'] || ( '' !== $slug_pro && $slug_pro === $plugin['slug'] ) ) ) {
1317 $not_found = false;
1318 break; // foreach.
1319 }
1320 }
1321 }
1322 }
1323
1324 if ( $not_found ) {
1325 $missing_installed[ $website->id ] = $website->name;
1326 }
1327 }
1328
1329 if ( empty( $missing_installed ) ) {
1330 return;
1331 }
1332
1333 $items_list_id = 'sync-sites-status';
1334 ?>
1335 <div class="ui modal" id="mainwp-install-check-modal" noti-slug="<?php echo esc_html( $check_slug ); ?>">
1336 <i class="mainwp-modal-close close icon"></i>
1337 <div class="header"><?php esc_html_e( 'Plugin Install Check', 'mainwp' ); ?></div>
1338 <div class="scrolling content mainwp-modal-content">
1339 <div class="ui message" id="mainwp-message-zone-install" style="display:none;"></div>
1340 <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>
1341 <div class="ui middle aligned divided list" id="<?php echo esc_attr( $items_list_id ); ?>">
1342 <?php foreach ( $missing_installed as $siteid => $site_name ) : ?>
1343 <div class="item siteBulkInstall" siteid="<?php echo intval( $siteid ); ?>" status="">
1344 <div class="right floated content">
1345 <span class="queue" data-inverted="" data-position="left center" data-tooltip="<?php echo esc_html__( 'Queued', 'mainwp' ); ?>"><i class="clock outline icon"></i></span>
1346 <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>
1347 <span class="status"></span>
1348 </div>
1349 <div class="content">
1350 <div class="ui checkbox checked">
1351 <input type="checkbox" checked="" id="install-check-<?php echo intval( $siteid ); ?>" name="install_checker[]"/>
1352 </div>
1353 <?php echo esc_html( $site_name ); ?>
1354 </div>
1355 </div>
1356 <?php endforeach; ?>
1357 </div>
1358 </div>
1359 <div class="actions mainwp-modal-actions">
1360 <div class="ui two columns grid">
1361 <div class="left aligned column">
1362
1363 </div>
1364 <div class="ui right aligned column">
1365 <input type="button" class="ui green button" id="mainwp-install-check-btn" value="<?php esc_html_e( 'Install Plugin', 'mainwp' ); ?>">
1366 </div>
1367 </div>
1368
1369 </div>
1370 </div>
1371 <script type="text/javascript">
1372 jQuery( document ).ready( function () {
1373 jQuery('#mainwp-install-check-modal').modal({
1374 allowMultiple: false,
1375 closable: false,
1376 onHide: function () {
1377 let noti_id = jQuery('#mainwp-install-check-modal').attr('noti-slug');
1378 mainwp_notice_dismiss(noti_id, 1);
1379 setTimeout(function () {
1380 mainwp_forceReload();
1381 }, 1000);
1382 },
1383 }).modal('show');
1384 jQuery(document).on('click', '#mainwp-install-check-btn', function () {
1385 mainwp_install_check_plugin_prepare( '<?php echo esc_js( rawurlencode( dirname( $plugin_slug ) ) ); ?>' );
1386 return false;
1387 });
1388 });
1389 </script>
1390 <?php
1391 }
1392 }
1393