base, $screens ) ) {
return;
}
// get installed plugins
$active_plugins = get_site_option( 'active_plugins' );
if ( empty( $active_plugins ) ) {
return;
}
$active_plugins_slug = array();
foreach ( $active_plugins as $plg ) {
$active_plugins_slug[] = explode( '/', $plg )[0];
}
$dp_plugins = onecom_fetch_plugins( $recommended = false, $discouraged = true );
// Get discouraged plugins list from transients
// Convert transient value to array
$dp_plugins = json_decode( json_encode( $dp_plugins ), true );
// Prepare discouraged plugins array
$disc_plugins = array();
foreach ( $dp_plugins as $plugin ) {
if ( isset( $plugin['slug'] ) && is_dir( WP_PLUGIN_DIR . '/' . $plugin['slug'] ) ) {
$plugin_info = get_plugins( '/' . $plugin['slug'] );
$disc_plugins[] = $plugin['slug'] . '/' . key( $plugin_info );
}
}
// Check if discouraged plugin(s) exist(s)
$active_disc_plugins = array_intersect( $disc_plugins, $active_plugins );
// Exit if no discouraged plugin is active
if ( empty( $active_disc_plugins ) ) {
return;
}
// If discouraged plugins exist, check for critical plugins
// Check and get the critic degree
$get_degrees = @array_column( $dp_plugins, 'degree' );
// Get critical plugins keys
$critical_keys = @array_keys( $get_degrees, 'high' );
// Prepare critical active plugins array
$crtical_active = array();
if ( ! empty( $critical_keys ) ) {
foreach ( $critical_keys as $value ) {
if ( is_dir( WP_PLUGIN_DIR . '/' . $dp_plugins[ $value ]['slug'] ) ) {
$plugin_info = get_plugins( '/' . $dp_plugins[ $value ]['slug'] );
$crtcl_path = $dp_plugins[ $value ]['slug'] . '/' . key( $plugin_info );
if ( is_plugin_active( $crtcl_path ) ) {
$crtical_active[] = $crtcl_path;
$plugin_file = $crtcl_path;
$plugin_name = reset( $plugin_info )['Name'];
}
}
}
}
// Check if any critical plugin active
if ( ! empty( $crtical_active ) && is_array( $crtical_active ) ) {
// Display Critical plugin warning
$text = sprintf( __( 'The plugin %s, that you are using, creates a lot of large temporary files causing high load on our servers and possible time-outs on your site.
We strongly advise you to deactivate it. If you keep on using this plugin we may be forced to suspend your site. ', 'onecom-wp' ), $plugin_name );
$link = '' . __( 'Deactivate' ) . '';
echo "
{$text} {$link}
{$text} {$title}