PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.1
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 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 5.1, at class/class-mainwp-system-view.php

1,262 lines 78.7 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 /**
11 * Class MainWP_System_View
12 *
13 * @package MainWP\Dashboard
14 */
15 class MainWP_System_View { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
16
17 /**
18 * Get Class Name
19 *
20 * @return string __CLASS__
21 */
22 public static function get_class_name() {
23 return __CLASS__;
24 }
25
26 /**
27 * Method get_mainwp_translations()
28 * Build Translations Array.
29 *
30 * @return array $mainwpTranslations.
31 */
32 public static function get_mainwp_translations() { // phpcs:ignore -- NOSONAR - complex.
33
34 /**
35 * Method mainwp_add_translation()
36 *
37 * Grab info needed to build array and strip chartacters "/[^A-Za-z0-9_]/".
38 *
39 * @param mixed $pArray Array of tranlatable text.
40 * @param mixed $pKey Key for each array enty.
41 * @param mixed $pText Text for each array entry.
42 */
43 function mainwp_add_translation( &$pArray, $pKey, $pText ) {
44 if ( ! is_array( $pArray ) ) {
45 $pArray = array();
46 }
47
48 $strippedText = str_replace( ' ', '_', $pKey );
49 $strippedText = preg_replace( '/[\W]/', '', $strippedText );
50
51 $pArray[ $strippedText ] = $pText;
52 }
53
54 $mainwpTranslations = array();
55 mainwp_add_translation( $mainwpTranslations, 'Update settings.', esc_html__( 'Update settings.', 'mainwp' ) );
56 mainwp_add_translation( $mainwpTranslations, 'Settings have been updated.', esc_html__( 'Settings have been updated.', 'mainwp' ) );
57 mainwp_add_translation( $mainwpTranslations, 'An error occured.', esc_html__( 'An error occured.', 'mainwp' ) );
58 mainwp_add_translation( $mainwpTranslations, 'Testing login.', esc_html__( 'Testing login.', 'mainwp' ) );
59 mainwp_add_translation( $mainwpTranslations, 'Your login is valid.', esc_html__( 'Your login is valid.', 'mainwp' ) );
60 mainwp_add_translation( $mainwpTranslations, 'Your login is invalid.', esc_html__( 'Your login is invalid.', 'mainwp' ) );
61 mainwp_add_translation( $mainwpTranslations, 'An error occured, please contact us.', esc_html__( 'An error occured, please contact us.', 'mainwp' ) );
62 mainwp_add_translation( $mainwpTranslations, 'more', esc_html__( 'more', 'mainwp' ) );
63 mainwp_add_translation( $mainwpTranslations, 'less', esc_html__( 'less', 'mainwp' ) );
64 mainwp_add_translation( $mainwpTranslations, 'An error occured: ', esc_html__( 'An error occured: ', 'mainwp' ) );
65 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' ) );
66 mainwp_add_translation( $mainwpTranslations, 'Undefined error.', esc_html__( 'Undefined error.', 'mainwp' ) );
67 mainwp_add_translation( $mainwpTranslations, 'PENDING', esc_html__( 'PENDING', 'mainwp' ) );
68 mainwp_add_translation( $mainwpTranslations, 'UPDATING', esc_html__( 'UPDATING', 'mainwp' ) );
69 mainwp_add_translation( $mainwpTranslations, 'UPGRADING', esc_html__( 'UPGRADING', 'mainwp' ) );
70 mainwp_add_translation( $mainwpTranslations, 'FAILED', esc_html__( 'FAILED', 'mainwp' ) );
71 mainwp_add_translation( $mainwpTranslations, 'DONE', esc_html__( 'DONE', 'mainwp' ) );
72 mainwp_add_translation( $mainwpTranslations, 'SYNCING', esc_html__( 'SYNCING', 'mainwp' ) );
73 mainwp_add_translation( $mainwpTranslations, 'DISCONNECTED', esc_html__( 'DISCONNECTED', 'mainwp' ) );
74 mainwp_add_translation( $mainwpTranslations, 'TIMEOUT', esc_html__( 'TIMEOUT', 'mainwp' ) );
75 mainwp_add_translation( $mainwpTranslations, 'Ignored', esc_html__( 'Ignored', 'mainwp' ) );
76 mainwp_add_translation( $mainwpTranslations, 'No ignored %1s', esc_html__( 'No ignored %1s', 'mainwp' ) );
77 mainwp_add_translation( $mainwpTranslations, 'No ignored %1 conflicts', esc_html__( 'No ignored %1 conflicts', 'mainwp' ) );
78 mainwp_add_translation( $mainwpTranslations, 'No ignored plugins', esc_html__( 'No ignored plugins', 'mainwp' ) );
79 mainwp_add_translation( $mainwpTranslations, 'No ignored themes', esc_html__( 'No ignored themes', 'mainwp' ) );
80 mainwp_add_translation( $mainwpTranslations, 'Upgrading..', esc_html__( 'Upgrading..', 'mainwp' ) );
81 mainwp_add_translation( $mainwpTranslations, 'Update successful', esc_html__( 'Update successful', 'mainwp' ) );
82 mainwp_add_translation( $mainwpTranslations, 'Update failed', esc_html__( 'Update failed', 'mainwp' ) );
83 mainwp_add_translation( $mainwpTranslations, 'Show All', esc_html__( 'Show All', 'mainwp' ) );
84 mainwp_add_translation( $mainwpTranslations, 'Show', esc_html__( 'Show', 'mainwp' ) );
85 mainwp_add_translation( $mainwpTranslations, 'Hide All', esc_html__( 'Hide All', 'mainwp' ) );
86 mainwp_add_translation( $mainwpTranslations, 'Hide', esc_html__( 'Hide', 'mainwp' ) );
87 mainwp_add_translation( $mainwpTranslations, 'Testing ...', esc_html__( 'Testing ...', 'mainwp' ) );
88 mainwp_add_translation( $mainwpTranslations, 'Test Settings', esc_html__( 'Test Settings', 'mainwp' ) );
89 mainwp_add_translation( $mainwpTranslations, 'Received wrong response from the server.', esc_html__( 'Received wrong response from the server.', 'mainwp' ) );
90 mainwp_add_translation( $mainwpTranslations, 'Untitled', esc_html__( 'Untitled', 'mainwp' ) );
91 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' ) );
92 mainwp_add_translation( $mainwpTranslations, 'Starting backup task.', esc_html__( 'Starting backup task.', 'mainwp' ) );
93 mainwp_add_translation( $mainwpTranslations, 'Cancel', esc_html__( 'Cancel', 'mainwp' ) );
94 mainwp_add_translation( $mainwpTranslations, 'Backup task complete', esc_html__( 'Backup task complete', 'mainwp' ) );
95 mainwp_add_translation( $mainwpTranslations, 'with errors', esc_html__( 'with errors', 'mainwp' ) );
96 mainwp_add_translation( $mainwpTranslations, 'Close', esc_html__( 'Close', 'mainwp' ) );
97 mainwp_add_translation( $mainwpTranslations, 'Creating backupfile.', esc_html__( 'Creating backupfile.', 'mainwp' ) );
98 mainwp_add_translation( $mainwpTranslations, 'Backupfile created successfully.', esc_html__( 'Backupfile created successfully.', 'mainwp' ) );
99 mainwp_add_translation( $mainwpTranslations, 'Download from child site completed.', esc_html__( 'Download from child site completed.', 'mainwp' ) );
100 mainwp_add_translation( $mainwpTranslations, 'Uploading to remote destinations..', esc_html__( 'Uploading to remote destinations..', 'mainwp' ) );
101 mainwp_add_translation( $mainwpTranslations, 'Backup complete.', esc_html__( 'Backup complete.', 'mainwp' ) );
102 mainwp_add_translation( $mainwpTranslations, 'Upload to %1 (%2) failed:', esc_html__( 'Upload to %1 (%2) failed:', 'mainwp' ) );
103 mainwp_add_translation( $mainwpTranslations, 'Upload to %1 (%2) succesful', esc_html__( 'Upload to %1 (%2) succesful', 'mainwp' ) );
104 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' ) );
105 mainwp_add_translation( $mainwpTranslations, 'Adding the task to MainWP', esc_html__( 'Adding the task to MainWP', 'mainwp' ) );
106 mainwp_add_translation( $mainwpTranslations, 'Please select websites or tags.', esc_html__( 'Please select websites or tags.', 'mainwp' ) );
107 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' ) );
108 mainwp_add_translation( $mainwpTranslations, 'Removing the task..', esc_html__( 'Removing the task..', 'mainwp' ) );
109 mainwp_add_translation( $mainwpTranslations, 'The task has been removed', esc_html__( 'The task has been removed', 'mainwp' ) );
110 mainwp_add_translation( $mainwpTranslations, 'An unspecified error occured', esc_html__( 'An unspecified error occured', 'mainwp' ) );
111 mainwp_add_translation( $mainwpTranslations, 'Connection test failed.', esc_html__( 'Connection test failed.', 'mainwp' ) );
112 mainwp_add_translation( $mainwpTranslations, 'Error message:', esc_html__( 'Error message:', 'mainwp' ) );
113 mainwp_add_translation( $mainwpTranslations, 'Received HTTP-code:', esc_html__( 'Received HTTP-code:', 'mainwp' ) );
114 mainwp_add_translation( $mainwpTranslations, 'Connection test successful.', esc_html__( 'Connection test successful.', 'mainwp' ) );
115 mainwp_add_translation( $mainwpTranslations, 'Invalid response from the server, please try again.', esc_html__( 'Invalid response from the server, please try again.', 'mainwp' ) );
116 mainwp_add_translation( $mainwpTranslations, 'Please enter csv file for upload.', esc_html__( 'Please enter csv file for upload.', 'mainwp' ) );
117 mainwp_add_translation( $mainwpTranslations, 'Please enter a name for the website', esc_html__( 'Please enter a name for the website', 'mainwp' ) );
118 mainwp_add_translation( $mainwpTranslations, 'Please enter a valid URL for your site', esc_html__( 'Please enter a valid URL for your site', 'mainwp' ) );
119 mainwp_add_translation( $mainwpTranslations, 'Please enter a username for the administrator', esc_html__( 'Please enter a username for the administrator', 'mainwp' ) );
120 mainwp_add_translation( $mainwpTranslations, 'Adding the site to MainWP', esc_html__( 'Adding the site to MainWP', 'mainwp' ) );
121 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' ) );
122 mainwp_add_translation( $mainwpTranslations, 'Testing the connection', esc_html__( 'Testing the connection', 'mainwp' ) );
123 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' ) );
124 mainwp_add_translation( $mainwpTranslations, 'Removing and deactivating the MainWP Child plugin..', esc_html__( 'Removing and deactivating the MainWP Child plugin..', 'mainwp' ) );
125 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' ) );
126 mainwp_add_translation( $mainwpTranslations, 'The requested site has not been found', esc_html__( 'The requested site has not been found', 'mainwp' ) );
127 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' ) );
128 mainwp_add_translation( $mainwpTranslations, 'Paused import by user.', esc_html__( 'Paused import by user.', 'mainwp' ) );
129 mainwp_add_translation( $mainwpTranslations, 'Continue', esc_html__( 'Continue', 'mainwp' ) );
130 mainwp_add_translation( $mainwpTranslations, 'Continue import.', esc_html__( 'Continue import.', 'mainwp' ) );
131 mainwp_add_translation( $mainwpTranslations, 'Pause', esc_html__( 'Pause', 'mainwp' ) );
132 mainwp_add_translation( $mainwpTranslations, 'Finished', esc_html__( 'Finished', 'mainwp' ) );
133 mainwp_add_translation( $mainwpTranslations, 'Please enter the Site name.', esc_html__( 'Please enter the Site name.', 'mainwp' ) );
134 mainwp_add_translation( $mainwpTranslations, 'Please enter the Site url.', esc_html__( 'Please enter the Site url.', 'mainwp' ) );
135 mainwp_add_translation( $mainwpTranslations, 'Please enter Admin name of the site.', esc_html__( 'Please enter Admin name of the site.', 'mainwp' ) );
136 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' ) );
137 mainwp_add_translation( $mainwpTranslations, 'HTTP error - website does not exist', esc_html__( 'HTTP error - website does not exist', 'mainwp' ) );
138 mainwp_add_translation( $mainwpTranslations, 'No selected Categories', esc_html__( 'No selected Categories', 'mainwp' ) );
139 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' ) );
140 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' ) );
141 mainwp_add_translation( $mainwpTranslations, 'Please enter the username.', esc_html__( 'Please enter the username.', 'mainwp' ) );
142 mainwp_add_translation( $mainwpTranslations, 'Please enter the email.', esc_html__( 'Please enter the email.', 'mainwp' ) );
143 mainwp_add_translation( $mainwpTranslations, 'Please enter the password.', esc_html__( 'Please enter the password.', 'mainwp' ) );
144 mainwp_add_translation( $mainwpTranslations, 'Please select a valid role.', esc_html__( 'Please select a valid role.', 'mainwp' ) );
145 mainwp_add_translation( $mainwpTranslations, 'Loading previous page..', esc_html__( 'Loading previous page..', 'mainwp' ) );
146 mainwp_add_translation( $mainwpTranslations, 'Loading next page..', esc_html__( 'Loading next page..', 'mainwp' ) );
147 mainwp_add_translation( $mainwpTranslations, 'Searching the WordPress repository..', esc_html__( 'Searching the WordPress repository..', 'mainwp' ) );
148 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' ) );
149 mainwp_add_translation( $mainwpTranslations, 'Queued', esc_html__( 'Queued', 'mainwp' ) );
150 mainwp_add_translation( $mainwpTranslations, 'In progress', esc_html__( 'In progress', 'mainwp' ) );
151 mainwp_add_translation( $mainwpTranslations, 'Preparing %1 installation.', esc_html__( 'Preparing %1 installation.', 'mainwp' ) );
152 mainwp_add_translation( $mainwpTranslations, 'Installation successful', esc_html__( 'Installation successful', 'mainwp' ) );
153 mainwp_add_translation( $mainwpTranslations, 'Installation failed', esc_html__( 'Installation failed', 'mainwp' ) );
154 mainwp_add_translation( $mainwpTranslations, 'Please select websites or tags to install files.', esc_html__( 'Please select websites or tags to install files.', 'mainwp' ) );
155 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' ) );
156 mainwp_add_translation( $mainwpTranslations, 'Backupfile on child site created successfully.', esc_html__( 'Backupfile on child site created successfully.', 'mainwp' ) );
157 mainwp_add_translation( $mainwpTranslations, 'Downloading the file.', esc_html__( 'Downloading the file.', 'mainwp' ) );
158 mainwp_add_translation( $mainwpTranslations, 'Download from child completed.', esc_html__( 'Download from child completed.', 'mainwp' ) );
159 mainwp_add_translation( $mainwpTranslations, 'Please wait while we are saving your note', esc_html__( 'Please wait while we are saving your note', 'mainwp' ) );
160 mainwp_add_translation( $mainwpTranslations, 'Note saved.', esc_html__( 'Note saved.', 'mainwp' ) );
161 mainwp_add_translation( $mainwpTranslations, 'An error occured while saving your message.', esc_html__( 'An error occured while saving your message.', 'mainwp' ) );
162 mainwp_add_translation( $mainwpTranslations, 'Please search and select users for update password.', esc_html__( 'Please search and select users for update password.', 'mainwp' ) );
163 mainwp_add_translation( $mainwpTranslations, 'All', esc_html__( 'All', 'mainwp' ) );
164 mainwp_add_translation( $mainwpTranslations, 'Any', esc_html__( 'Any', 'mainwp' ) );
165 mainwp_add_translation( $mainwpTranslations, 'HTTP error', esc_html__( 'HTTP error', 'mainwp' ) );
166 mainwp_add_translation( $mainwpTranslations, 'Error on your child WordPress', esc_html__( 'Error on your child WordPress', 'mainwp' ) );
167 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' ) );
168 mainwp_add_translation( $mainwpTranslations, 'Remove', esc_html__( 'Remove', 'mainwp' ) );
169 mainwp_add_translation( $mainwpTranslations, 'Please reconnect to Dropbox', esc_html__( 'Please reconnect to Dropbox', 'mainwp' ) );
170 mainwp_add_translation( $mainwpTranslations, 'Please wait', esc_html__( 'Please wait', 'mainwp' ) );
171 mainwp_add_translation( $mainwpTranslations, 'Upgrading all', esc_html__( 'Upgrading all', 'mainwp' ) );
172 mainwp_add_translation( $mainwpTranslations, 'Upgrading %1', esc_html__( 'Upgrading %1', 'mainwp' ) );
173 mainwp_add_translation( $mainwpTranslations, 'Updating your plan...', esc_html__( 'Updating your plan...', 'mainwp' ) );
174 mainwp_add_translation( $mainwpTranslations, 'Updated your plan', esc_html__( 'Updated your plan', 'mainwp' ) );
175 $mainwp_backup_before_upgrade_days = get_option( 'mainwp_backup_before_upgrade_days' );
176 if ( empty( $mainwp_backup_before_upgrade_days ) || ! ctype_digit( $mainwp_backup_before_upgrade_days ) ) {
177 $mainwp_backup_before_upgrade_days = 7;
178 }
179 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' ) ) );
180 mainwp_add_translation( $mainwpTranslations, 'Starting required backup(s).', esc_html__( 'Starting required backup(s).', 'mainwp' ) );
181 mainwp_add_translation( $mainwpTranslations, 'Required backup(s) complete', esc_html__( 'Required backup(s) complete', 'mainwp' ) );
182 mainwp_add_translation( $mainwpTranslations, 'Continue update anyway', esc_html__( 'Continue update anyway', 'mainwp' ) );
183 mainwp_add_translation( $mainwpTranslations, 'Continue update', esc_html__( 'Continue update', 'mainwp' ) );
184 mainwp_add_translation( $mainwpTranslations, 'Pause', esc_html__( 'Pause', 'mainwp' ) );
185 mainwp_add_translation( $mainwpTranslations, 'Resume', esc_html__( 'Resume', 'mainwp' ) );
186 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' ) );
187 mainwp_add_translation( $mainwpTranslations, 'Full backup required', esc_html__( 'Full backup required', 'mainwp' ) );
188 mainwp_add_translation( $mainwpTranslations, 'Checking backup settings', esc_html__( 'Checking backup settings', 'mainwp' ) );
189 mainwp_add_translation( $mainwpTranslations, 'Hide Shortcuts', esc_html__( 'Hide Shortcuts', 'mainwp' ) );
190 mainwp_add_translation( $mainwpTranslations, 'Show Shortcuts', esc_html__( 'Show Shortcuts', 'mainwp' ) );
191 mainwp_add_translation( $mainwpTranslations, 'Are you sure?', esc_html__( 'Are you sure?', 'mainwp' ) );
192 mainwp_add_translation( $mainwpTranslations, 'Bulk reconnect finished.', esc_html__( 'Bulk reconnect finished.', 'mainwp' ) );
193 mainwp_add_translation( $mainwpTranslations, 'Note Saved', esc_html__( 'Note Saved', 'mainwp' ) );
194 mainwp_add_translation( $mainwpTranslations, 'An error occured while saving your message', esc_html__( 'An error occured while saving your message', 'mainwp' ) );
195 mainwp_add_translation( $mainwpTranslations, 'Download from child site completed.', esc_html__( 'Download from child site completed.', 'mainwp' ) );
196 mainwp_add_translation( $mainwpTranslations, 'Please wait while we are saving your note', esc_html__( 'Please wait while we are saving your note', 'mainwp' ) );
197 mainwp_add_translation( $mainwpTranslations, 'Installation Successful', esc_html__( 'Installation Successful', 'mainwp' ) );
198 mainwp_add_translation( $mainwpTranslations, 'Upload to %1 (%2) successful.', esc_html__( 'Upload to %1 (%2) successful.', 'mainwp' ) );
199 mainwp_add_translation( $mainwpTranslations, 'Upload to %1 (%2) failed:', esc_html__( 'Upload to %1 (%2) failed:', 'mainwp' ) );
200 mainwp_add_translation( $mainwpTranslations, 'Updating Themes', esc_html__( 'Updating Themes', 'mainwp' ) );
201 mainwp_add_translation( $mainwpTranslations, 'Updating Plugins', esc_html__( 'Updating Plugins', 'mainwp' ) );
202 mainwp_add_translation( $mainwpTranslations, 'Updating WordPress', esc_html__( 'Updating WordPress', 'mainwp' ) );
203 mainwp_add_translation( $mainwpTranslations, 'updated', esc_html__( 'updated', 'mainwp' ) );
204 mainwp_add_translation( $mainwpTranslations, 'Updating', esc_html__( 'Updating', 'mainwp' ) );
205 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' ) );
206 mainwp_add_translation( $mainwpTranslations, 'The backup task was added successfully', esc_html__( 'The backup task was added successfully', 'mainwp' ) );
207 mainwp_add_translation( $mainwpTranslations, 'Bulk test connection finished', esc_html__( 'Bulk test connection finished', 'mainwp' ) );
208 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' ) );
209 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' ) );
210 mainwp_add_translation( $mainwpTranslations, 'No ignored abandoned plugins', esc_html__( 'No ignored abandoned plugins', 'mainwp' ) );
211 mainwp_add_translation( $mainwpTranslations, 'Please upload plugins to install.', esc_html__( 'Please upload plugins to install.', 'mainwp' ) );
212 mainwp_add_translation( $mainwpTranslations, 'Please upload themes to install.', esc_html__( 'Please upload themes to install.', 'mainwp' ) );
213 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' ) );
214 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' ) );
215 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' ) );
216 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' ) );
217 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' ) );
218 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' ) );
219 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' ) );
220 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' ) );
221 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' ) );
222 mainwp_add_translation( $mainwpTranslations, 'is_activated_theme', esc_html__( '%1 could not be deleted. This theme is active theme.', 'mainwp' ) );
223
224 return $mainwpTranslations;
225 }
226
227 /**
228 * Check if MainWP Extensions are Activated or not.
229 *
230 * @param mixed $plugin_slug Plugin Slug.
231 *
232 * @return string Activation warning message.
233 *
234 * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_indexed_extensions_infor()
235 */
236 public static function after_extensions_plugin_row( $plugin_slug ) {
237 $extensions = MainWP_Extensions_Handler::get_indexed_extensions_infor();
238 if ( ! isset( $extensions[ $plugin_slug ] ) ) {
239 return;
240 }
241
242 if ( ! isset( $extensions[ $plugin_slug ]['apiManager'] ) || ! $extensions[ $plugin_slug ]['apiManager'] ) {
243 return;
244 }
245
246 if ( isset( $extensions[ $plugin_slug ]['activated_key'] ) && 'Activated' === $extensions[ $plugin_slug ]['activated_key'] ) {
247 return;
248 }
249
250 $slug = basename( $plugin_slug, '.php' );
251
252 $activate_notices = get_user_option( 'mainwp_hide_activate_notices' );
253 if ( is_array( $activate_notices ) && isset( $activate_notices[ $slug ] ) ) {
254 return;
255 }
256 ?>
257 <style type="text/css">
258 tr[data-plugin="<?php echo esc_attr( $plugin_slug ); ?>"] {
259 box-shadow: none;
260 }
261 </style>
262 <tr class="plugin-update-tr active" slug="<?php echo esc_attr( $slug ); ?>"><td colspan="3" class="plugin-update colspanchange"><div class="update-message api-deactivate">
263 <?php 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>' ); ?>
264 <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>
265 </div></td></tr>
266 <?php
267 }
268
269 /**
270 * MainWP Version 4 update Notice.
271 *
272 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
273 */
274 public static function mainwp_4_update_notice() {
275 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_4' ) ) {
276 ?>
277 <div class="ui icon message yellow" style="margin-bottom: 0; border-radius: 0;">
278 <i class="exclamation circle icon"></i>
279 <strong><?php echo esc_html__( 'Important Notice: ', 'mainwp' ); ?></strong>&nbsp;<?php 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://kb.mainwp.com/docs/faq-on-upgrading-from-mainwp-version-3-to-mainwp-version-4/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. ?>
280 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_4"></i>
281 </div>
282 <?php
283 }
284 }
285
286 /**
287 * MainWP Version ver 5 update Notice.
288 *
289 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
290 */
291 public static function mainwp_ver5_update_notice() {
292 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_version5' ) ) {
293 ?>
294 <div class="ui modal" id="mainwp-v5-update-notice-modal">
295 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_version5"></i>
296 <div class="header">
297 <?php echo esc_html__( 'MainWP 5.0 Update Notice', 'mainwp' ); ?>
298 </div>
299 <div class="content">
300 <h3 class="ui header">
301 <i class="sync alternate icon"></i>
302 <div class="content">
303 <?php echo esc_html__( 'Hard Refresh Required', 'mainwp' ); ?>
304
305 </div>
306 </h3>
307 <div class="ui hidden divider"></div>
308 <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>
309 <br/>
310 <div><?php echo esc_html__( 'This step is crucial for loading the latest updates effectively.', 'mainwp' ); ?></div>
311 <div class="ui list">
312 <div class="item"><i class="windows icon"></i> <?php echo esc_html__( 'Windows users: Press `Ctrl + F5`', 'mainwp' ); ?></div>
313 <div class="item"><i class="apple icon"></i> <?php echo esc_html__( 'Mac users: Press `Command + R`', 'mainwp' ); ?></div>
314 <div class="item"><i class="linux icon"></i> <?php echo esc_html__( 'Linux users: Press `F5`', 'mainwp' ); ?></div>
315 </div>
316
317 <div class="ui divider"></div>
318
319 <h3 class="ui header">
320 <i class="linkify icon"></i>
321 <div class="content">
322 <?php echo esc_html__( 'Extensions License Reactivation Required', 'mainwp' ); ?>
323
324 </div>
325 </h3>
326 <div class="ui hidden divider"></div>
327 <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>
328 <br/>
329 <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>
330
331 <div class="ui divider"></div>
332
333 <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>
334 <div class="ui hidden divider"></div>
335 <div><?php echo esc_html__( 'Thank you for using MainWP!', 'mainwp' ); ?></div>
336 </div>
337 </div>
338 <script type="text/javascript">
339 jQuery( document ).ready( function() {
340 jQuery( '#mainwp-v5-update-notice-modal' ).modal({
341 onHidden: function () {
342 let notice_id = jQuery( '#mainwp-v5-update-notice-modal' ).find('.mainwp-notice-dismiss').attr('notice-id');
343 let data = {
344 action: 'mainwp_notice_status_update'
345 };
346 data['notice_id'] = notice_id;
347 jQuery.post(ajaxurl, mainwp_secure_data(data), function () { });
348 },
349 }).modal('show');
350 });
351 </script>
352 <?php
353 }
354 }
355
356 /**
357 * MainWP Version ver 5 update Notice.
358 *
359 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
360 */
361 public static function mainwp_ver502_update_notice() {
362 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_version502' ) ) {
363 ?>
364 <div class="ui modal" id="mainwp-v502-update-notice-modal">
365 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_version502"></i>
366 <div class="header">
367 <?php echo esc_html__( 'MainWP 5.0.2 Update Notice', 'mainwp' ); ?>
368 </div>
369 <div class="content">
370 <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>
371 <br/>
372 <div><?php echo esc_html__( 'This step is crucial for loading the latest updates effectively.', 'mainwp' ); ?></div>
373 <div class="ui list">
374 <div class="item"><i class="windows icon"></i> <?php echo esc_html__( 'Windows users: Press `Ctrl + F5`', 'mainwp' ); ?></div>
375 <div class="item"><i class="apple icon"></i> <?php echo esc_html__( 'Mac users: Press `Command + R`', 'mainwp' ); ?></div>
376 <div class="item"><i class="linux icon"></i> <?php echo esc_html__( 'Linux users: Press `F5`', 'mainwp' ); ?></div>
377 </div>
378 </div>
379 </div>
380 <script type="text/javascript">
381 jQuery( document ).ready( function() {
382 jQuery( '#mainwp-v502-update-notice-modal' ).modal({
383 onHidden: function () {
384 let notice_id = jQuery( '#mainwp-v502-update-notice-modal' ).find('.mainwp-notice-dismiss').attr('notice-id');
385 let data = {
386 action: 'mainwp_notice_status_update'
387 };
388 data['notice_id'] = notice_id;
389 jQuery.post(ajaxurl, mainwp_secure_data(data), function () { });
390 },
391 }).modal('show');
392 });
393 </script>
394 <?php
395 }
396 }
397
398 /**
399 * MainWP Version ver 5 update Notice.
400 *
401 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
402 */
403 public static function mainwp_ver5_update_clear_cache_notice() {
404 if ( MainWP_Utility::show_mainwp_message( 'notice', 'upgrade_ver5_clear_cache' ) ) {
405 ?>
406 <div class="ui message info" style="margin-bottom: 0; border-radius: 0;">
407 <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>
408 <div class="ui list">
409 <div class="item"><?php echo esc_html__( 'Windows users: Press `Ctrl + F5`', 'mainwp' ); ?></div>
410 <div class="item"><?php echo esc_html__( 'Mac users: Press `Command + R`', 'mainwp' ); ?></div>
411 <div class="item"><?php echo esc_html__( 'Linux users: Press `F5`', 'mainwp' ); ?></div>
412 </div>
413 <i class="close icon mainwp-notice-dismiss" notice-id="upgrade_ver5_clear_cache"></i>
414 </div>
415 <?php
416 }
417 }
418
419
420 /**
421 * Render Administration Notice.
422 *
423 * @uses \MainWP\Dashboard\MainWP_System::is_mainwp_pages()
424 * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::check_auto_update_plugin()
425 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_openssl_config_warning()
426 */
427 public static function admin_notices() {
428
429 $current_options = get_option( 'mainwp_showhide_events_notice' );
430 if ( ! is_array( $current_options ) ) {
431 $current_options = array();
432 }
433
434 static::render_notice_version();
435
436 static::render_notice_config_warning();
437
438 if ( is_multisite() && ( ! isset( $current_options['hide_multi_site_notice'] ) || empty( $current_options['hide_multi_site_notice'] ) ) ) {
439 static::render_notice_multi_sites();
440 }
441
442 if ( ( ! 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' ) ) {
443 static::render_notice_trust_update();
444 }
445
446 static::render_trours_notice();
447
448 static::check_rating_notice( $current_options );
449
450 static::render_wp_mail_warning();
451
452 static::render_browser_extensions_notice();
453
454 static::mainwp_tmpfile_check();
455 }
456
457 /**
458 * Method mainwp_tmpfile_check()
459 *
460 * Checks if the `tmpfile()` PHP function is disabled.
461 */
462 public static function mainwp_tmpfile_check() {
463 if ( MainWP_Demo_Handle::is_instawp_site() ) {
464 return;
465 }
466 $disabled_functions = ini_get( 'disable_functions' );
467 if ( '' !== $disabled_functions ) {
468 $disabled_functions_array = explode( ',', $disabled_functions );
469 if ( in_array( 'tmpfile', $disabled_functions_array ) && MainWP_Utility::show_mainwp_message( 'notice', 'tmpfile_notice' ) ) {
470 ?>
471 <div class="ui red message" style="margin-bottom: 0; border-radius: 0;">
472 <i class="close icon mainwp-notice-dismiss" notice-id="tmpfile_notice"></i>
473 <div><?php esc_html_e( 'tmpfile() function is currently disabled on your server.', 'mainwp' ); ?></div>
474 <div><?php esc_html_e( 'This function is essential for creating temporary files, and its unavailability may affect certain functionalities of your MainWP Dashboard.', 'mainwp' ); ?></div>
475 <div><?php esc_html_e( 'If you are unsure how to enable it, please contact your host support and have them do it for you.', 'mainwp' ); ?></div>
476 </div>
477 <?php
478 }
479 }
480 }
481
482
483 /**
484 * Renders Browsers extensions notice.
485 *
486 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
487 */
488 public static function render_browser_extensions_notice() {
489 $is_demo = MainWP_Demo_Handle::is_demo_mode();
490 if ( MainWP_DB::instance()->get_websites_count() > 4 && ! $is_demo && MainWP_Utility::show_mainwp_message( 'notice', 'mainwp_browser_extensions_notice' ) ) {
491 ?>
492 <div class="ui info message" style="margin-bottom: 0; border-radius: 0;">
493 <h3><?php esc_html_e( 'Track Updates and Non-MainWP Changes from Your Browser!', 'mainwp' ); ?></h3>
494 <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>
495 <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>
496 <br/>
497 <div>
498 <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>
499 <a href="https://addons.mozilla.org/en-US/firefox/addon/mainwp-browser-extension/" target="_blank" class="ui green tiny button"><i class="firefox icon"></i> <?php echo esc_html__( 'Get Firefox Extension', 'mainwp' ); ?></a>
500 <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>
501 </div>
502 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp_browser_extensions_notice"></i>
503 </div>
504 <?php
505 }
506 }
507
508 /**
509 * Renders wp_mail warning.
510 */
511 public static function render_wp_mail_warning() {
512 $mail_failed = get_option( 'mainwp_notice_wp_mail_failed' );
513 if ( 'yes' === $mail_failed ) {
514 ?>
515 <div class="ui yellow message" style="margin-bottom: 0; border-radius: 0;">
516 <?php echo esc_html__( 'wp_mail() error detected! It is more than likely that your MainWP Dashboard will fail to send any email. Please check for possible plugin conflicts with your Dashboard or contact your host support to determine why the wp_mail() function fails.', 'mainwp' ); ?>
517 <i class="close icon mainwp-notice-dismiss" notice-id="mail_failed"></i>
518 </div>
519 <?php
520 }
521 }
522
523 /**
524 * Renders PHP Version Notice.
525 *
526 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
527 */
528 public static function render_notice_version() {
529 $phpver = phpversion();
530 if ( version_compare( $phpver, '7.0', '<' ) && MainWP_Utility::show_mainwp_message( 'notice', 'phpver_5_5' ) ) {
531 ?>
532 <div class="ui icon yellow message" style="margin-bottom: 0; border-radius: 0;">
533 <i class="exclamation circle icon"></i>
534 <?php printf( esc_html__( 'Your server is currently running PHP version %1$s. In the next few months your MainWP Dashboard will require PHP 7.4 as a minimum. Please upgrade your server to at least 7.4 but we recommend PHP 8 or newer. You can find a template email to send your host %2$shere%3$s.', 'mainwp' ), esc_html( $phpver ), '<a href="https://wordpress.org/about/requirements/" target="_blank">', '</a>' ); ?>
535 <i class="close icon mainwp-notice-dismiss" notice-id="phpver_5_5"></i>
536 </div>
537 <?php
538 }
539 }
540
541 /**
542 * Renders Guided Tours Notice.
543 *
544 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
545 */
546 public static function render_trours_notice() {
547 if ( 0 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) && MainWP_Utility::show_mainwp_message( 'notice', 'mainwp_guided_tours_notice' ) ) {
548 ?>
549 <div class="ui info message" style="margin-bottom: 0; border-radius: 0;">
550 <h3><?php esc_html_e( 'Would you like to turn on guided tours?', 'mainwp' ); ?> <span class="ui green mini label"><?php esc_html_e( 'RECOMMENDED', 'mainwp' ); ?></span></h3>
551 <div><?php esc_html_e( 'MainWP guided tours are designed to provide information about all essential features on each MainWP Dashboard page.', 'mainwp' ); ?></div>
552 <div class="ui form">
553 <div class="field">
554 <div class="ui hidden divider"></div>
555 <div class="ui toggle checkbox">
556 <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"' : ''; ?>>
557 <label for="mainwp-select-guided-tours-option"><?php esc_html_e( 'Select to enable the MainWP Guided Tours.', 'mainwp' ); ?></label>
558 </div>
559 </div>
560 </div>
561 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp_guided_tours_notice"></i>
562 </div>
563 <?php
564 }
565 }
566
567 /**
568 * Renders OpenSSL Error message.
569 *
570 * @uses \MainWP\Dashboard\MainWP_Utility::show_mainwp_message()
571 */
572 public static function render_notice_config_warning() {
573 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
574 ?>
575 <div class="ui yellow message" style="margin-bottom: 0; border-radius: 0;">
576 <button class="ui mini button yellow close icon mainwp-notice-dismiss" style="top:30%;margin-right:10px !important" notice-id="ssl_warn"><?php echo esc_html__( 'Error Fixed', 'mainwp' ); ?></button>
577 <div><?php printf( esc_html__( 'MainWP has detected that the&nbsp;%1$sOpenSSL.cnf%2$s&nbsp;file is not configured properly. It is required to configure this so you can start connecting your child sites. Please,&nbsp;%3$sclick here to configure it!%4$s', 'mainwp' ), '<strong>', '</strong>', '<a href="admin.php?page=SettingsAdvanced">', '</a>' ); ?></div>
578 <div><?php echo esc_html__( 'If your MainWP Dashboard has no issues with connecting child sites, you can dismiss this warning by clicking the Error Fixed button.', 'mainwp' ); ?></div>
579 </div>
580 <?php
581 }
582 }
583
584 /** Renders WP Multisite Error Message. */
585 public static function render_notice_multi_sites() {
586 ?>
587 <div class="ui icon red message" style="margin-bottom: 0; border-radius: 0;">
588 <i class="exclamation circle icon"></i>
589 <?php esc_html_e( 'MainWP plugin is not designed nor fully tested on WordPress Multisite installations. Various features may not work properly. We highly recommend installing it on a single site installation!', 'mainwp' ); ?>
590 <i class="close icon mainwp-notice-dismiss" notice-id="multi_site"></i>
591 </div>
592 <?php
593 }
594
595 /**
596 * Renders MainWP Review Request.
597 *
598 * @param bool $current_options false|true Weather or not to display request.
599 *
600 * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_extensions()
601 */
602 public static function check_rating_notice( $current_options ) { // phpcs:ignore -- NOSONAR - complex.
603 $display_request1 = false;
604 $display_request2 = false;
605
606 if ( isset( $current_options['request_reviews1'] ) ) {
607 if ( 'forever' === $current_options['request_reviews1'] ) {
608 $display_request1 = false;
609 } else {
610 $days = intval( $current_options['request_reviews1'] );
611 $start_time = $current_options['request_reviews1_starttime'];
612 $display_request1 = ( ( time() - $start_time ) > $days * 24 * 3600 ) ? true : false;
613 }
614 } else {
615 $current_options['request_reviews1'] = 30;
616 $current_options['request_reviews1_starttime'] = time();
617 update_option( 'mainwp_showhide_events_notice', $current_options );
618 }
619
620 if ( isset( $current_options['request_reviews2'] ) ) {
621 if ( 'forever' === $current_options['request_reviews2'] ) {
622 $display_request2 = false;
623 } else {
624 $days = intval( $current_options['request_reviews2'] );
625 $start_time = $current_options['request_reviews2_starttime'];
626 $display_request2 = ( ( time() - $start_time ) > $days * 24 * 3600 ) ? true : false;
627 }
628 } else {
629 $currentExtensions = MainWP_Extensions_Handler::get_extensions();
630 if ( is_array( $currentExtensions ) && count( $currentExtensions ) > 10 ) {
631 $display_request2 = true;
632 }
633 }
634
635 if ( $display_request1 ) {
636 static::render_rating_notice_1();
637 } elseif ( $display_request2 ) {
638 static::render_rating_notice_2();
639 }
640 }
641
642 /** Renders MainWP Dashboard & Child Plugin auto update Alert. */
643 public static function render_notice_trust_update() {
644 $is_demo = MainWP_Demo_Handle::is_demo_mode();
645 if ( ! $is_demo ) {
646 ?>
647 <div class="ui blue message" style="margin-bottom: 0; border-radius: 0;">
648 <?php esc_html_e( 'Do you want MainWP Child to be updated automatically on your websites? This is highly recommended!', 'mainwp' ); ?>
649 <div class="ui hidden divider"></div>
650 <a id="mainwp_btn_autoupdate_and_trust" class="ui mini green button" href="#"><?php esc_html_e( 'Update MainWP Child Plugin Automatically', 'mainwp' ); ?></a>
651 <i class="close icon mainwp-events-notice-dismiss" notice="trust_child"></i>
652 </div>
653 <?php
654 }
655 }
656
657 /** Renders MainWP 30 day review request. */
658 public static function render_rating_notice_1() {
659 ?>
660 <div class="ui green icon message" style="margin-bottom: 0; border-radius: 0;">
661 <i class="star icon"></i>
662 <div class="content">
663 <p><?php esc_html_e( 'Hi, I noticed you have been using MainWP for over 30 days and that\'s awesome!', 'mainwp' ); ?></p>
664 <p><?php esc_html_e( 'Could you please do me a BIG favor and give it a 5-star rating? Reviews from users like YOU really help the MainWP community to grow.', 'mainwp' ); ?></p>
665 <div class="ui green floating mini labeled icon dropdown button">
666 <i class="star icon"></i>
667 <span class="text">Rate MainWP</span>
668 <div class="menu">
669 <a href="https://wordpress.org/support/plugin/mainwp/reviews/#new-post" class="item" target="_blank">
670 <span class="text">WordPress.org</span>
671 </a>
672 <a href="https://www.trustpilot.com/review/mainwp.com" class="item" target="_blank">
673 <span class="text">Trustpilot</span>
674 </a>
675 <a href="https://www.g2.com/products/mainwp/reviews" class="item" target="_blank">
676 <span class="text">G2</span>
677 </a>
678 </div>
679 </div>
680 <a href="" class="ui mini green basic button mainwp-events-notice-dismiss" notice="request_reviews1"><?php esc_html_e( 'Nope, maybe later.', 'mainwp' ); ?></a>
681 <a href="" class="ui mini green basic button mainwp-events-notice-dismiss" notice="request_reviews1_forever"><?php esc_html_e( 'I already did.', 'mainwp' ); ?></a>
682 </div>
683 <i class="close icon mainwp-events-notice-dismiss" notice="request_reviews1_forever"></i>
684 </div>
685 <?php
686 }
687
688 /** Renders MainWP review notice after a few extensions have been installed. */
689 public static function render_rating_notice_2() {
690 ?>
691 <div class="ui green icon message" style="margin-bottom: 0; border-radius: 0;">
692 <i class="star icon"></i>
693 <div class="content">
694 <p><?php esc_html_e( 'Hi, I noticed you have a few MainWP Extensions installed and that\'s awesome!', 'mainwp' ); ?></p>
695 <p><?php esc_html_e( 'Could you please do me a BIG favor and give it a 5-star rating? Reviews from users like YOU really help the MainWP community to grow.', 'mainwp' ); ?></p>
696 <div class="ui green floating mini labeled icon dropdown button">
697 <i class="star icon"></i>
698 <span class="text">Rate MainWP</span>
699 <div class="menu">
700 <a href="https://wordpress.org/support/plugin/mainwp/reviews/#new-post" class="item" target="_blank">
701 <span class="text">WordPress.org</span>
702 </a>
703 <a href="https://www.trustpilot.com/review/mainwp.com" class="item" target="_blank">
704 <span class="text">Trustpilot</span>
705 </a>
706 <a href="https://www.g2.com/products/mainwp/reviews" class="item" target="_blank">
707 <span class="text">G2</span>
708 </a>
709 </div>
710 </div>
711 <a href="" class="ui mini green basic button mainwp-events-notice-dismiss" notice="request_reviews2"><?php esc_html_e( 'Nope, maybe later.', 'mainwp' ); ?></a>
712 <a href="" class="ui mini green basic button mainwp-events-notice-dismiss" notice="request_reviews2_forever"><?php esc_html_e( 'I already did.', 'mainwp' ); ?></a>
713 </div>
714 <i class="close icon mainwp-events-notice-dismiss" notice="request_reviews2_forever"></i>
715 </div>
716 <?php
717 }
718
719 /** Renders Send Mail Function may have failed error. */
720 public static function wp_admin_notices() {
721
722 /**
723 * Current pagenow.
724 *
725 * @global string
726 */
727 global $pagenow;
728
729 if ( 'plugins.php' !== $pagenow ) {
730 return;
731 }
732
733 $deactivated_exts = get_transient( 'mainwp_transient_deactivated_incomtible_exts' );
734 if ( $deactivated_exts && is_array( $deactivated_exts ) && ! empty( $deactivated_exts ) ) {
735 ?>
736 <div class='notice notice-error my-dismiss-notice is-dismissible'>
737 <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>
738 </div>
739 <?php
740 }
741 }
742
743
744 /**
745 * Method admin_footer()
746 *
747 * Renders admin footer.
748 */
749 public static function admin_footer() {
750 $disabled_confirm = get_option( 'mainwp_disable_update_confirmations', 0 );
751 ?>
752 <input type="hidden" id="mainwp-disable-update-confirmations" value="<?php echo intval( $disabled_confirm ); ?>">
753
754 <script type="text/javascript">
755 jQuery( document ).ready(
756 function ()
757 {
758 jQuery( '#adminmenu #collapse-menu' ).hide();
759 }
760 );
761 </script>
762 <?php
763 /**
764 * Filter: mainwp_open_hide_referrer
765 *
766 * Filters whether the MainWP should hide referrer when going to child site.
767 *
768 * @since Unknown
769 */
770 $hide_ref = apply_filters( 'mainwp_open_hide_referrer', false );
771 if ( $hide_ref ) {
772 ?>
773 <script type="text/javascript">
774 jQuery( document ).on( 'click', 'a.mainwp-may-hide-referrer', function ( e ) {
775 e.preventDefault();
776 mainwp_open_hide_referrer( e.target.href );
777 } );
778
779 function mainwp_open_hide_referrer( url ) {
780 let ran = Math.floor( Math.random() * 100 ) + 1;
781 let site = window.open( "", "mainwp_hide_referrer_" + ran );
782 let meta = site.document.createElement( 'meta' );
783 meta.name = "referrer";
784 meta.content = "no-referrer";
785 site.document.getElementsByTagName( 'head' )[0].appendChild( meta );
786 site.document.open();
787 site.document.writeln( '<script type="text/javascript">window.location = "' + url + '";<\/script>' );
788 site.document.close();
789 }
790 </script>
791 <?php
792 }
793 }
794
795 /**
796 * Admin print styles.
797 *
798 * @uses \MainWP\Dashboard\MainWP_System::is_mainwp_pages()
799 */
800 public static function admin_print_styles() {
801 ?>
802 <style>
803 <?php
804 if ( MainWP_System::is_mainwp_pages() ) {
805 ?>
806 #wpbody-content > div.update-nag,
807 #wpbody-content > div.updated {
808 margin-left: 190px;
809 }
810 html.wp-toolbar{
811 padding-top: 0 !important;
812 }
813 <?php
814 }
815 ?>
816 .mainwp-checkbox:before {
817 content: '<?php esc_html_e( 'YES', 'mainwp' ); ?>';
818 }
819 .mainwp-checkbox:after {
820 content: '<?php esc_html_e( 'NO', 'mainwp' ); ?>';
821 }
822 </style>
823 <?php
824 }
825
826
827 /**
828 * Productions site warning.
829 *
830 * Renders the warning if the production site is detected.
831 *
832 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count()
833 */
834 public static function mainwp_warning_notice() {
835 if ( 'yes' === get_option( 'mainwp_installation_warning_hide_the_notice' ) ) {
836 return;
837 }
838 if ( MainWP_DB::instance()->get_websites_count() > 0 ) {
839 return;
840 } else {
841 $plugins = get_plugins();
842 if ( ! is_array( $plugins ) || count( $plugins ) <= 4 ) {
843 return;
844 }
845 }
846 ?>
847 <div class="ui red message" style="margin-bottom: 0; border-radius: 0;">
848 <h4><?php esc_html_e( 'This appears to be a production site', 'mainwp' ); ?></h4>
849 <?php esc_html_e( 'We HIGHLY recommend a NEW WordPress install for your MainWP Dashboard.', 'mainwp' ); ?> <?php 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>")' ); ?>
850 <br /><br />
851 <a href="#" class="ui red mini button" id="remove-mainwp-installation-warning"><?php esc_html_e( 'I have read the warning and I want to proceed', 'mainwp' ); ?></a>
852 </div>
853 <?php
854 }
855
856 /** Render Admin Header */
857 public static function admin_head() {
858 ?>
859 <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>
860 <?php
861 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
862 static::mainwp_usetiful_tours();
863 }
864 }
865
866 /**
867 * Render usetiful tours.
868 */
869 public static function mainwp_usetiful_tours() {
870 echo "
871 <script>
872 (function (w, d, s) {
873 console.log('init usetifulScript');
874 let a = d.getElementsByTagName('head')[0];
875 let r = d.createElement('script');
876 r.async = 1;
877 r.src = s;
878 r.setAttribute('id', 'usetifulScript');
879 r.dataset.token = '480fa17b0507a1c60abba94bfdadd0a7';
880 a.appendChild(r);
881 })(window, document, 'https://www.usetiful.com/dist/usetiful.js');</script>
882 ";
883 }
884
885 /**
886 * MainWP Admin body CSS class attributes.
887 *
888 * @param mixed $class_string MainWP CSS Class attributes.
889 *
890 * @return string $class_string The CSS attributes to add to the page.
891 *
892 * @uses \MainWP\Dashboard\MainWP_System::is_mainwp_pages()
893 */
894 public static function admin_body_class( $class_string ) { // phpcs:ignore -- NOSONAR - complex.
895 if ( MainWP_System::is_mainwp_pages() ) {
896 $class_string .= ' mainwp-ui mainwp-ui-page ';
897 $class_string .= ' mainwp-ui-leftmenu ';
898
899 $selected_theme = MainWP_Settings::get_instance()->get_selected_theme();
900 if ( ! empty( $selected_theme ) ) {
901 $class_string .= ' mainwp-custom-theme ';
902 }
903
904 if ( ! empty( $selected_theme ) && is_string( $selected_theme ) ) {
905 $class_string .= ' mainwp-' . $selected_theme . '-theme ';
906 } else {
907 $class_string .= ' mainwp-classic-theme ';
908 }
909
910 $siteViewMode = MainWP_Utility::get_siteview_mode();
911 if ( 'grid' === $siteViewMode ) {
912 $class_string .= ' mainwp-sites-grid-view ';
913 } else {
914 $class_string .= ' mainwp-sites-table-view ';
915 }
916
917 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
918 if ( isset( $_GET['page'] ) && 'managesites' === $_GET['page'] && isset( $_GET['dashboard'] ) && ! empty( $_GET['dashboard'] ) ) {
919 $class_string .= ' mainwp-individual-site-overview ';
920 }
921
922 if ( isset( $_GET['page'] ) && 'ManageClients' === $_GET['page'] && isset( $_GET['client_id'] ) && ! empty( $_GET['client_id'] ) ) {
923 $class_string .= ' mainwp-individual-client-overview ';
924 }
925 if ( isset( $_GET['page'] ) && ( 'ServerInformation' === $_GET['page'] || 'ServerInformationCron' === $_GET['page'] || 'ErrorLog' === $_GET['page'] || 'ActionLogs' === $_GET['page'] || 'PluginPrivacy' === $_GET['page'] || 'Settings' === $_GET['page'] || 'SettingsAdvanced' === $_GET['page'] || 'SettingsEmail' === $_GET['page'] || 'MainWPTools' === $_GET['page'] || 'SettingsInsights' === $_GET['page'] || 'SettingsApiBackups' === $_GET['page'] ) ) {
926 $class_string .= ' mainwp-individual-site-view ';
927 }
928 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['emailsettingsid'] ) && ! empty( $_GET['emailsettingsid'] ) ) || ( isset( $_GET['scanid'] ) && ! empty( $_GET['scanid'] ) ) ) ) {
929 $class_string .= ' mainwp-individual-site-view ';
930 }
931 // phpcs:enable
932 $class_string = apply_filters( 'mainwp_page_admin_body_class', $class_string );
933 }
934 return $class_string;
935 }
936
937 /**
938 * Method render_footer_content()
939 *
940 * Render footer content.
941 *
942 * @param mixed $websites The websites object.
943 * @param int $current_wpid The current website id.
944 *
945 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
946 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
947 * @uses \MainWP\Dashboard\MainWP_Utility::get_nice_url()
948 */
949 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.
950 if ( is_array( $websites ) ) {
951 $count = count( $websites );
952 for ( $i = 0; $i < $count; $i++ ) {
953 $website = $websites[ $i ];
954 echo '<input type="hidden" name="dashboard_wp_ids[]" class="dashboard_wp_id" error-status="' . ( empty( $website->sync_errors ) ? 0 : 1 ) . '" value="' . intval( $website->id ) . '" />';
955 }
956 } elseif ( false !== $websites ) {
957 while ( $website = MainWP_DB::fetch_object( $websites ) ) {
958 echo '<input type="hidden" name="dashboard_wp_ids[]" class="dashboard_wp_id" error-status="' . ( empty( $website->sync_errors ) ? 0 : 1 ) . '" value="' . intval( $website->id ) . '" />';
959 }
960 }
961 /**
962 * Action: mainwp_admin_footer
963 *
964 * Fires at the bottom of MainWP content.
965 *
966 * @since Unknown
967 */
968 do_action( 'mainwp_admin_footer' );
969 MainWP_UI::render_select_mainwp_themes_modal();
970 MainWP_UI::render_install_extensions_promo_modal();
971 ?>
972 <div class="ui modal" id="mainwp-sync-sites-modal" current-wpid="<?php echo intval( $current_wpid ); ?>">
973 <i class="mainwp-modal-close close icon"></i>
974 <div class="header"><?php esc_html_e( 'Data Synchronization', 'mainwp' ); ?></div>
975 <div class="ui green progress mainwp-modal-progress">
976 <div class="bar"><div class="progress"></div></div>
977 <div class="label"></div>
978 </div>
979 <div class="scrolling content mainwp-modal-content">
980 <div class="ui middle aligned divided selection list" id="sync-sites-status">
981 <?php
982 if ( is_array( $websites ) ) {
983 $count = count( $websites );
984 for ( $i = 0; $i < $count; $i++ ) {
985 $site_name = $website->name;
986 $website = $websites[ $i ];
987 $is_sync_err = ( '' !== $website->sync_errors ) ? true : false;
988 ?>
989 <div class="item <?php echo $is_sync_err ? 'disconnected-site' : ''; ?>">
990 <div class="right floated content">
991 <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>
992 </div>
993 <div class="content">
994 <?php echo esc_html( $site_name ); ?>
995 <?php do_action( 'mainwp_sync_popup_content', $website ); ?>
996 </div>
997 </div>
998 <?php
999 }
1000 } else {
1001 MainWP_DB::data_seek( $websites, 0 );
1002 while ( $website = MainWP_DB::fetch_object( $websites ) ) {
1003 $site_name = $website->name;
1004 $is_sync_err = ( '' !== $website->sync_errors ) ? true : false;
1005 ?>
1006 <div class="item <?php echo $is_sync_err ? 'disconnected-site' : ''; ?>">
1007 <div class="right floated content">
1008 <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>
1009 </div>
1010 <div class="content">
1011 <?php echo esc_html( $site_name ); ?>
1012 <?php do_action( 'mainwp_sync_popup_content', $website ); ?>
1013 </div>
1014 </div>
1015 <?php
1016 }
1017 }
1018 ?>
1019 </div>
1020 </div>
1021 </div>
1022 <input type="hidden" id="sync_selected_site_ids" value="" />
1023 <div class="ui tiny modal" id="mainwp-modal-confirm-select">
1024 <i class="close icon"></i>
1025 <div class="header"><?php esc_html_e( 'Confirmation', 'mainwp' ); ?></div>
1026 <div class="content">
1027 <div class="content-massage"></div>
1028 </div>
1029 <div class="actions">
1030 </div>
1031 </div>
1032 <?php
1033 static::render_comfirm_modal();
1034 }
1035
1036 /**
1037 * Method render_comfirm_modal()
1038 *
1039 * Render comfirm modal box.
1040 */
1041 public static function render_comfirm_modal() {
1042 ?>
1043 <div class="ui tiny modal" id="mainwp-modal-confirm">
1044 <i class="close icon"></i>
1045 <div class="header"><?php esc_html_e( 'Confirmation', 'mainwp' ); ?></div>
1046 <div class="content">
1047 <div class="content-massage"></div>
1048 <div class="ui mini yellow message hidden update-confirm-notice" ><?php 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>
1049 <div class="ui form hidden" id="mainwp-confirm-form" style="display:none;">
1050 <div class="ui divider"></div>
1051 <div class="field">
1052 <label></label>
1053 <input type="text" id="mainwp-confirm-input" name="mainwp-confirm-input">
1054 </div>
1055 </div>
1056 </div>
1057 <div class="actions">
1058 <div class="ui two columns grid">
1059 <div class="ui left aligned column">
1060 </div>
1061 <div class="ui right aligned column">
1062 <div class="ui green positive button"><?php esc_html_e( 'Yes, proceed!', 'mainwp' ); ?></div>
1063 </div>
1064 </div>
1065 </div>
1066 </div>
1067 <?php
1068 }
1069
1070 /**
1071 * Method get_plugins_install_check()
1072 *
1073 * Get plugins for install checking.
1074 */
1075 public static function get_plugins_install_check() {
1076 $plugins = array(
1077 array(
1078 'page' => 'Extensions-Mainwp-Pro-Reports-Extension',
1079 'slug' => 'mainwp-child-reports/mainwp-child-reports.php',
1080 'name' => 'MainWP Child Reports',
1081 ),
1082 array(
1083 'page' => 'Extensions-Mainwp-Client-Reports-Extension',
1084 'slug' => 'mainwp-child-reports/mainwp-child-reports.php',
1085 'name' => 'MainWP Child Reports',
1086 ),
1087 array(
1088 'page' => 'Extensions-Mainwp-Backwpup-Extension',
1089 'slug' => 'backwpup/backwpup.php',
1090 'name' => 'BackWPup',
1091 ),
1092 array(
1093 'page' => 'Extensions-Mainwp-Ithemes-Security-Extension',
1094 'slug' => 'better-wp-security/better-wp-security.php',
1095 'slug_pro' => 'ithemes-security-pro/ithemes-security-pro.php',
1096 'name' => 'iThemes Security',
1097 ),
1098 array(
1099 'page' => 'Extensions-Mainwp-Updraftplus-Extension',
1100 'slug' => 'updraftplus/updraftplus.php',
1101 'name' => 'UpdraftPlus',
1102 ),
1103 array(
1104 'page' => 'Extensions-Mainwp-Wordfence-Extension',
1105 'slug' => 'wordfence/wordfence.php',
1106 'name' => 'Wordfence',
1107 ),
1108 array(
1109 'page' => 'Extensions-Wordpress-Seo-Extension',
1110 'slug' => 'wordpress-seo/wp-seo.php',
1111 'name' => 'Yoast SEO',
1112 ),
1113 array(
1114 'page' => 'Extensions-Mainwp-Jetpack-Protect-Extension',
1115 'slug' => 'jetpack-protect/jetpack-protect.php',
1116 'name' => 'Jetpack Protect',
1117 ),
1118 array(
1119 'page' => 'Extensions-Mainwp-Jetpack-Scan-Extension',
1120 'slug' => 'jetpack-protect/jetpack-protect.php', // tweaked: to requires install the JP protect plugin.
1121 'slug_pro' => 'jetpack/jetpack.php',
1122 'name' => 'Jetpack Protect',
1123 ),
1124 );
1125 return apply_filters( 'mainwp_plugins_install_checks', $plugins );
1126 }
1127
1128 /**
1129 * Render plugins install check modal.
1130 * for the exntesion overview page with the missing install plugin only.
1131 */
1132 public static function render_plugins_install_check() { // phpcs:ignore -- NOSONAR - complex function.
1133
1134 $plugins_to_checks = static::get_plugins_install_check();
1135
1136 $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1137
1138 $plugin_check = MainWP_Utility::get_sub_array_having( $plugins_to_checks, 'page', $page );
1139
1140 if ( ! empty( $plugin_check ) ) {
1141 $plugin_check = current( $plugin_check );
1142 }
1143
1144 if ( empty( $plugin_check ) ) {
1145 return;
1146 }
1147
1148 // if is not overview extension page return.
1149 if ( isset( $_GET['tab'] ) && 'overview' !== $_GET['tab'] && 'dashboard' !== $_GET['tab'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1150 return;
1151 }
1152
1153 $plugin_slug = isset( $plugin_check['slug'] ) ? $plugin_check['slug'] : '';
1154 $slug_pro = isset( $plugin_check['slug_pro'] ) ? $plugin_check['slug_pro'] : '';
1155 $plugin_name = isset( $plugin_check['name'] ) ? $plugin_check['name'] : '';
1156
1157 if ( empty( $plugin_slug ) || empty( $plugin_name ) ) {
1158 return;
1159 }
1160
1161 $check_slug = 'install_check_' . sanitize_text_field( wp_unslash( dirname( $plugin_slug ) ) );
1162 $check_hidetime = MainWP_Utility::get_hide_notice_status( $check_slug );
1163
1164 if ( $check_hidetime && time() < $check_hidetime + 30 * DAY_IN_SECONDS ) {
1165 return;
1166 }
1167
1168 $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() );
1169
1170 if ( empty( $websites ) ) {
1171 return;
1172 }
1173
1174 $missing_installed = array();
1175
1176 while ( $websites && $website = MainWP_DB::fetch_object( $websites ) ) {
1177 $site_name = $website->name;
1178 if ( '' !== $website->sync_errors ) {
1179 continue;
1180 }
1181 $not_found = true;
1182 if ( '' !== $website->plugins ) {
1183 $plugins = json_decode( $website->plugins, 1 );
1184 if ( is_array( $plugins ) && ! empty( $plugins ) ) {
1185 foreach ( $plugins as $plugin ) {
1186 if ( isset( $plugin['slug'] ) && ( $plugin_slug === $plugin['slug'] || ( '' !== $slug_pro && $slug_pro === $plugin['slug'] ) ) ) {
1187 $not_found = false;
1188 break; // foreach.
1189 }
1190 }
1191 }
1192 }
1193
1194 if ( $not_found ) {
1195 $missing_installed[ $website->id ] = $website->name;
1196 }
1197 }
1198
1199 if ( empty( $missing_installed ) ) {
1200 return;
1201 }
1202
1203 ?>
1204 <div class="ui modal" id="mainwp-install-check-modal" noti-slug="<?php echo esc_html( $check_slug ); ?>">
1205 <i class="mainwp-modal-close close icon"></i>
1206 <div class="header"><?php esc_html_e( 'Plugin Install Check', 'mainwp' ); ?></div>
1207 <div class="scrolling content mainwp-modal-content">
1208 <div class="ui message" id="mainwp-message-zone-install" style="display:none;"></div>
1209 <div class="ui message blue"><?php 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>
1210 <div class="ui middle aligned divided selection list" id="sync-sites-status">
1211 <?php foreach ( $missing_installed as $siteid => $site_name ) : ?>
1212 <div class="item siteBulkInstall" siteid="<?php echo intval( $siteid ); ?>" status="">
1213 <div class="right floated content">
1214 <span class="queue" data-inverted="" data-position="left center" data-tooltip="<?php echo esc_html__( 'Queued', 'mainwp' ); ?>"><i class="clock outline icon"></i></span>
1215 <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>
1216 <span class="status"></span>
1217 </div>
1218 <div class="content">
1219 <div class="ui checkbox checked">
1220 <input type="checkbox" checked="" id="install-check-<?php echo intval( $siteid ); ?>" name="install_checker[]"/>
1221 </div>
1222 <?php echo esc_html( $site_name ); ?>
1223 </div>
1224 </div>
1225 <?php endforeach; ?>
1226 </div>
1227 </div>
1228 <div class="actions mainwp-modal-actions">
1229 <div class="ui two columns grid">
1230 <div class="left aligned column">
1231
1232 </div>
1233 <div class="ui right aligned column">
1234 <input type="button" class="ui green button" id="mainwp-install-check-btn" value="<?php esc_html_e( 'Install Plugin', 'mainwp' ); ?>">
1235 </div>
1236 </div>
1237
1238 </div>
1239 </div>
1240 <script type="text/javascript">
1241 jQuery( document ).ready( function () {
1242 jQuery('#mainwp-install-check-modal').modal({
1243 allowMultiple: false,
1244 closable: false,
1245 onHide: function () {
1246 let noti_id = jQuery('#mainwp-install-check-modal').attr('noti-slug');
1247 mainwp_notice_dismiss(noti_id, 1);
1248 setTimeout(function () {
1249 window.location.href = location.href;
1250 }, 1000);
1251 },
1252 }).modal('show');
1253 jQuery(document).on('click', '#mainwp-install-check-btn', function () {
1254 mainwp_install_check_plugin_prepare( '<?php echo esc_js( rawurlencode( dirname( $plugin_slug ) ) ); ?>' );
1255 return false;
1256 });
1257 });
1258 </script>
1259 <?php
1260 }
1261 }
1262