PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / trunk
MainWP Dashboard: Self-hosted WordPress Management for Agencies vtrunk
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
← All changes | widgets/widget-mainwp-widget-plugins.php +62 -20 5.2trunk View file →
@@ -8,8 +8,13 @@
8 8 */
9 9
10 10 namespace MainWP\Dashboard;
11 11
12 +// Exit if accessed directly.
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit;
15 +}
16 +
12 17 /**
13 18 * Class MainWP_Widget_Plugins
14 19 */
15 20 class MainWP_Widget_Plugins { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
@@ -119,12 +124,23 @@
119 124
120 125 $inactive_plugins = MainWP_Utility::get_sub_array_having( $allPlugins, 'active', 0 );
121 126 $inactive_plugins = MainWP_Utility::sortmulti( $inactive_plugins, 'name', 'asc' );
122 127
128 + $wp_info = MainWP_DB::instance()->get_website_option( $website, 'site_info' );
129 + $wp_info = ! empty( $wp_info ) ? json_decode( $wp_info, true ) : array();
130 +
131 + if ( ! is_array( $wp_info ) ) {
132 + $wp_info = array();
133 + }
134 +
135 + $use_tzformat = ! empty( $wp_info['format_datetime'] ) && is_array( $wp_info['format_datetime'] ) ? $wp_info['format_datetime'] : array();
136 + $offs = ! empty( $use_tzformat['gmt_offset'] ) ? intval( $use_tzformat['gmt_offset'] ) : 0;
137 + $offs_info = esc_html__( ' - Timezone:', 'mainwp' ) . ' UTC' . ( $offs >= 0 ? '+' . $offs : $offs );
138 +
123 139 ?>
124 140 <div class="ui grid mainwp-widget-header">
125 141 <div class="twelve wide column">
126 - <h3 class="ui header handle-drag">
142 + <h2 class="ui header handle-drag">
127 143 <?php
128 144 /**
129 145 * Filter: mainwp_plugins_widget_title
130 146 *
@@ -136,14 +152,13 @@
136 152 */
137 153 echo esc_html( apply_filters( 'mainwp_plugins_widget_title', esc_html__( 'Plugins', 'mainwp' ), $website ) );
138 154 ?>
139 155 <div class="sub header"><?php esc_html_e( 'Installed plugins on the child site', 'mainwp' ); ?></div>
140 - </h3>
156 + </h2>
141 157 </div>
142 158 <div class="four wide column right aligned">
143 159 <div class="ui dropdown right pointing mainwp-dropdown-tab">
144 - <div class="text"><?php esc_html_e( 'Active', 'mainwp' ); ?></div>
145 - <i class="dropdown icon"></i>
160 + <i class="vertical ellipsis icon"></i>
146 161 <div class="menu">
147 162 <a class="item" data-tab="active_plugins" data-value="active_plugins" title="<?php esc_attr_e( 'Active', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Active', 'mainwp' ); ?></a>
148 163 <a class="item" data-tab="inactive_plugins" data-value="inactive_plugins" title="<?php esc_attr_e( 'Inactive', 'mainwp' ); ?>" href="#"><?php esc_html_e( 'Inactive', 'mainwp' ); ?></a>
149 164 </div>
@@ -162,10 +177,11 @@
162 177 *
163 178 * @since 4.1
164 179 */
165 180 do_action( 'mainwp_plugins_widget_top', $website, $allPlugins );
181 + $site_info = $website->name . ' (' . $website->url . ') ' . ( ! empty( $offs_info ) ? $offs_info : '' );
166 182 ?>
167 - <div id="mainwp-widget-active-plugins" class="ui tab active" data-tab="active_plugins">
183 + <div id="mainwp-widget-active-plugins" class="ui tab active" data-tab="active_plugins" site-info="<?php echo esc_attr( $site_info ); ?>" site-id="<?php echo intval( $website->id ); ?>">
168 184 <?php
169 185 /**
170 186 * Action: mainwp_before_active_plugins_list
171 187 *
@@ -183,21 +199,33 @@
183 199 $_count = count( $actived_plugins );
184 200 for ( $i = 0; $i < $_count; $i++ ) {
185 201 $slug = wp_strip_all_tags( $actived_plugins[ $i ]['slug'] );
186 202 $plugin_directory = dirname( $slug );
203 + $plugin_name = $actived_plugins[ $i ]['name'];
204 + $plugin_title = $plugin_name . ' ' . $actived_plugins[ $i ]['version'];
187 205 ?>
188 - <div class="item <?php echo esc_html( dirname( $slug ) ); ?> row-manage-item">
206 + <div class="item <?php echo esc_html( dirname( $slug ) ); ?> row-manage-item" plugin-title="<?php echo esc_attr( $plugin_title ); ?>" plugin-name="<?php echo esc_attr( $plugin_name ); ?>" plugin-slug="<?php echo esc_attr( $slug ); ?>">
189 207 <input class="pluginSlug" type="hidden" name="slug" value="<?php echo esc_attr( wp_strip_all_tags( $actived_plugins[ $i ]['slug'] ) ); ?>"/>
190 208 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/>
191 209 <div class="right floated pluginsAction">
192 - <?php if ( mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) { ?>
193 - <span data-position="left center" data-tooltip="<?php echo esc_attr__( 'Deactivate the ', 'mainwp' ) . esc_html( $actived_plugins[ $i ]['name'] ) . ' ' . esc_attr__( 'plugin on the child site.', 'mainwp' ); ?>" data-inverted=""><div class="mainwp-plugin-deactivate ui mini button green <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Deactivate', 'mainwp' ); ?></div></span>
194 - <?php } ?>
210 + <div class="ui right pointing dropdown">
211 + <i class="ellipsis vertical icon"></i>
212 + <div class="menu">
213 + <?php if ( \mainwp_current_user_can( 'dashboard', 'activate_deactivate_plugins' ) ) { ?>
214 + <div class="mainwp-plugin-deactivate item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Deactivate', 'mainwp' ); ?></div>
215 + <?php } ?>
216 + <?php if ( \mainwp_current_user_can( 'dashboard', 'delete_plugins' ) ) { ?>
217 + <a href="#" class="mainwp-plugin-delete item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Delete', 'mainwp' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></a>
218 + <?php } ?>
219 + <a href="#" history-view="widget-plugins" class="mainwp-show-history item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'History', 'mainwp' ); ?></a>
220 + </div>
221 + </div>
222 +
195 223 </div>
196 224 <div class="middle aligned content">
197 225 <?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); // phpcs:ignore WordPress.Security.EscapeOutput ?>&nbsp;&nbsp;&nbsp;&nbsp;
198 226 <a href="<?php echo esc_url( admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_html( dirname( wp_strip_all_tags( $actived_plugins[ $i ]['slug'] ) ) ) ); ?>" target="_blank" class="open-plugin-details-modal" title="More information about <?php echo wp_strip_all_tags( $actived_plugins[ $i ]['name'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?>">
199 - <?php echo esc_html( $actived_plugins[ $i ]['name'] . ' ' . $actived_plugins[ $i ]['version'] ); ?>
227 + <?php echo esc_html( $plugin_title ); ?>
200 228 </a>
201 229 </div>
202 230 <div class="mainwp-row-actions-working">
203 231 <i class="notched circle loading icon"></i> <?php esc_html_e( 'Please wait...', 'mainwp' ); ?>
@@ -232,30 +260,38 @@
232 260 * @since 4.1
233 261 */
234 262 do_action( 'mainwp_before_inactive_plugins_list', $website, $inactive_plugins );
235 263 ?>
236 - <div class="ui middle aligned divided selection list">
264 + <div class="ui middle aligned divided list">
237 265 <?php
238 266 $_count = count( $inactive_plugins );
239 267 for ( $i = 0; $i < $_count; $i++ ) {
240 268 $slug = $inactive_plugins[ $i ]['slug'];
241 269 $plugin_directory = dirname( $slug );
270 + $plugin_name = $inactive_plugins[ $i ]['name'];
271 + $plugin_title = $plugin_name . ' ' . $inactive_plugins[ $i ]['version'];
242 272 ?>
243 - <div class="item <?php echo esc_html( sanitize_text_field( dirname( $slug ) ) ); ?> row-manage-item">
273 + <div class="item <?php echo esc_html( sanitize_text_field( dirname( $slug ) ) ); ?> row-manage-item" plugin-title="<?php echo esc_attr( $plugin_title ); ?>" plugin-name="<?php echo esc_attr( $plugin_name ); ?>" plugin-slug="<?php echo esc_attr( $slug ); ?>">
244 274 <input class="pluginSlug" type="hidden" name="slug" value="<?php echo esc_attr( wp_strip_all_tags( $inactive_plugins[ $i ]['slug'] ) ); ?>"/>
245 275 <input class="websiteId" type="hidden" name="id" value="<?php echo esc_attr( $website->id ); ?>"/>
246 276 <div class="right floated content pluginsAction">
247 - <?php if ( mainwp_current_user_have_right( 'dashboard', 'activate_deactivate_plugins' ) ) { ?>
248 - <span data-position="left center" data-tooltip="<?php echo esc_attr__( 'Activate the ', 'mainwp' ) . wp_strip_all_tags( $inactive_plugins[ $i ]['name'] ) . ' ' . esc_attr__( 'plugin on the child site.', 'mainwp' ); ?>" data-inverted=""><a href="#" class="mainwp-plugin-activate ui mini green button <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Activate', 'mainwp' );// phpcs:ignore WordPress.Security.EscapeOutput ?></a></span>
249 - <?php } ?>
250 - <?php if ( mainwp_current_user_have_right( 'dashboard', 'delete_plugins' ) ) { ?>
251 - <span data-position="left center" data-tooltip="<?php echo esc_attr__( 'Delete the ', 'mainwp' ) . wp_strip_all_tags( $inactive_plugins[ $i ]['name'] ) . ' ' . esc_attr__( 'plugin from the child site.', 'mainwp' ); ?>" data-inverted=""><a href="#" class="mainwp-plugin-delete ui mini basic button <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Delete', 'mainwp' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></a></span>
252 - <?php } ?>
277 + <div class="ui right pointing dropdown">
278 + <i class="ellipsis vertical icon"></i>
279 + <div class="menu">
280 + <?php if ( \mainwp_current_user_can( 'dashboard', 'activate_deactivate_plugins' ) ) { ?>
281 + <a href="#" class="mainwp-plugin-activate item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Activate', 'mainwp' );// phpcs:ignore WordPress.Security.EscapeOutput ?></a>
282 + <?php } ?>
283 + <?php if ( \mainwp_current_user_can( 'dashboard', 'delete_plugins' ) ) { ?>
284 + <a href="#" class="mainwp-plugin-delete item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'Delete', 'mainwp' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></a>
285 + <?php } ?>
286 + <a href="#" history-view="widget-plugins" class="mainwp-show-history item <?php echo $is_demo ? 'disabled' : ''; ?>"><?php esc_html_e( 'History', 'mainwp' ); ?></a>
287 + </div>
288 + </div>
253 289 </div>
254 290 <div class="middle aligned content">
255 291 <?php echo MainWP_System_Utility::get_plugin_icon( $plugin_directory ); // phpcs:ignore WordPress.Security.EscapeOutput ?>&nbsp;&nbsp;&nbsp;&nbsp;
256 292 <a href="<?php echo esc_url( admin_url() . 'plugin-install.php?tab=plugin-information&wpplugin=' . intval( $website->id ) . '&plugin=' . esc_html( dirname( $inactive_plugins[ $i ]['slug'] ) ) ); ?>" target="_blank" class="open-plugin-details-modal" title="More information about <?php echo wp_strip_all_tags( $inactive_plugins[ $i ]['name'] ); // phpcs:ignore WordPress.Security.EscapeOutput ?>">
257 - <?php echo esc_html( $inactive_plugins[ $i ]['name'] . ' ' . $inactive_plugins[ $i ]['version'] ); ?>
293 + <?php echo esc_html( $plugin_title ); ?>
258 294 </a>
259 295 </div>
260 296 <div class="mainwp-row-actions-working">
261 297 <i class="ui active inline loader tiny"></i> <?php esc_html_e( 'Please wait...', 'mainwp' ); ?>
@@ -277,8 +313,14 @@
277 313 do_action( 'mainwp_after_inactive_plugins_list', $website, $inactive_plugins );
278 314 ?>
279 315 </div>
280 316 </div>
317 + <div class="ui two column grid mainwp-widget-footer">
318 + <div class="left aligned middle aligned column"></div>
319 + <div class="right aligned middle aligned column">
320 + <a href="admin.php?page=PluginsManage" class="ui mini basic button"><?php esc_html_e( 'Manage Plugins', 'mainwp' ); ?></a>
321 + </div>
322 + </div>
281 323 <?php
282 324 /**
283 325 * Action: mainwp_plugins_widget_bottom
284 326 *
@@ -392,9 +434,9 @@
392 434 */
393 435 do_action( 'mainwp_after_plugin_action', $information, $action, $plugin, $website );
394 436
395 437 } catch ( MainWP_Exception $e ) {
396 - die( wp_json_encode( array( 'error' => MainWP_Error_Helper::get_error_message( $e ) ) ) );
438 + die( wp_json_encode( array( 'error' => MainWP_Error_Helper::get_error_message( $e, true ) ) ) ); // escaped.
397 439 }
398 440
399 441 if ( ! isset( $information['status'] ) || ( 'SUCCESS' !== $information['status'] ) ) {
400 442 die( wp_json_encode( array( 'error' => esc_html__( 'Unexpected error occurred. Please try again.', 'mainwp' ) ) ) );