Skip to content

Commit

Permalink
Added more plugin warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawngee committed Nov 2, 2018
1 parent 1602485 commit 587db56
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 28 deletions.
51 changes: 29 additions & 22 deletions classes/Tools/ToolBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use function ILAB\MediaCloud\Utilities\arrayPath;
use ILAB\MediaCloud\Utilities\EnvironmentOptions;
use ILAB\MediaCloud\Utilities\NoticeManager;
use ILAB\MediaCloud\Utilities\View;


Expand Down Expand Up @@ -142,10 +143,10 @@ protected function testForBadPlugins() {

if (isset($this->toolInfo['badPlugins'])) {
$installedBad = [];
foreach($this->toolInfo['badPlugins'] as $name => $pluginFile) {
if (is_plugin_active($pluginFile)) {
foreach($this->toolInfo['badPlugins'] as $name => $plugin) {
if (is_plugin_active($plugin['plugin'])) {
$this->badPluginsInstalled = true;
$installedBad[$name] = $pluginFile;
$installedBad[$name] = $plugin;
}
}

Expand All @@ -170,36 +171,42 @@ protected function testForUselessPlugins() {

if (isset($this->toolInfo['uselessPlugins'])) {
$installedBad = [];
foreach($this->toolInfo['uselessPlugins'] as $name => $pluginFile) {
if (is_plugin_active($pluginFile)) {
$installedBad[$name] = $pluginFile;
$installedBadNames = [];

foreach($this->toolInfo['uselessPlugins'] as $name => $plugin) {
if (is_plugin_active($plugin['plugin'])) {
$installedBad[$name] = $plugin;
$installedBadNames[] = sanitize_title($name);
}
}

if (count($installedBad) > 0) {
add_action( 'admin_notices', function () use ($installedBad) {
?>
<div class="notice notice-warning" style="padding:10px;">
<div style="text-transform: uppercase; font-weight:bold; opacity: 0.8; margin-bottom: 0; padding-bottom: 0">Media Cloud</div>
<p>The following plugins don't work well with <?php echo $this->toolInfo['name'] ?>. Consider deactivating them because they are completely useless:</p>
<?php $this->generatePluginTable($installedBad) ?>
</div>
<?php
} );
$dismissibleID = 'useless-plugins-'.implode('-', $installedBadNames).'-7';
if (NoticeManager::instance()->isAdminNoticeActive($dismissibleID)) {
add_action( 'admin_notices', function () use ($installedBad, $dismissibleID) {
?>
<div data-dismissible="<?php echo $dismissibleID ?>" class="notice notice-warning is-dismissible" style="padding:10px;">
<div style="text-transform: uppercase; font-weight:bold; opacity: 0.8; margin-bottom: 0; padding-bottom: 0">Media Cloud</div>
<p>The following plugins don't work well with <?php echo $this->toolInfo['name'] ?> or they don't work as you might expect they should. Consider deactivating them or finding an alternative that works better:</p>
<?php $this->generatePluginTable($installedBad) ?>
</div>
<?php
} );
}
}
}
}

private function generatePluginTable($installedBad) {
?>
<table>
<?php foreach($installedBad as $name => $plug) : ?>
<tr>
<td style="font-weight:bold; padding:10px 30px 10px 0px;"><?php echo $name ?></td>
<td style="font-weight:bold; padding:10px 0px 10px 0px;"><a class="button button-small" href="<?php echo $this->generateDeactivateLink($name, $plug)?>">Deactivate</a></td>
</tr>
<ul style="padding: 15px; background-color: #EAEAEA;">
<?php foreach($installedBad as $name => $plugin) : ?>
<li style="margin-bottom: 10px;">
<div style="display:flex; align-items: center; font-weight:bold; margin-bottom: 10px;"><?php echo $name ?> <a style="margin-left: 15px;" class="button button-small" href="<?php echo $this->generateDeactivateLink($name, $plugin['plugin'])?>">Deactivate</a></div>
<cite><?php echo $plugin['description'] ?></cite>
</li>
<?php endforeach; ?>
</table>
</ul>
<?php
}

Expand Down
6 changes: 4 additions & 2 deletions config/imgix.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
"ilab-imgix-helpers.php"
],
"badPlugins" => [
"BuddyPress" => "buddypress/bp-loader.php",
"MetaSlider" => "ml-slider/ml-slider.php"
"BuddyPress" => [
"plugin" => "buddypress/bp-loader.php",
"description" => "Uploading profile or cover images results in broken images."
]
],
"settings" => [
"title" => "Imgix Settings",
Expand Down
28 changes: 24 additions & 4 deletions config/storage.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,32 @@
"env" => "ILAB_MEDIA_S3_ENABLED",
"dependencies" => [],
"uselessPlugins" => [
"Imagify" => "imagify/imagify.php",
"EWWW Image Optimizer" => "ewww-image-optimizer/ewww-image-optimizer.php",
"ShortPixel Image Optimizer" => "shortpixel-image-optimiser/wp-shortpixel.php",
"Smush" => "wp-smushit/wp-smush.php",
"Imagify" => [
"plugin" => "imagify/imagify.php",
"description" => "This image optimizer attempts to optimize images in the background, after the upload has happened. This is incompatible with how Media Cloud works."
],
"EWWW Image Optimizer" => [
"plugin" => "ewww-image-optimizer/ewww-image-optimizer.php",
"description" => "This image optimizer attempts to optimize images in the background, after the upload has happened. This is incompatible with how Media Cloud works."
],
"ShortPixel Image Optimizer" => [
"plugin" => "shortpixel-image-optimiser/wp-shortpixel.php",
"description" => "This image optimizer attempts to optimize images in the background, after the upload has happened. This is incompatible with how Media Cloud works."
],
"Smush" => [
"plugin" => "wp-smushit/wp-smush.php",
"description" => "This image optimizer attempts to optimize images in the background, after the upload has happened. This is incompatible with how Media Cloud works."
],
"NextGEN Gallery" => [
"plugin" => "nextgen-gallery/nggallery.php",
"description" => "NextGEN Gallery has their own media upload system that works outside of the WordPress one. Obviously, this is not compatible with Media Cloud. To be honest, we can't figure out why they do it this way and their codebase is too gnarly to untangle. This plugin DOES work, but the media will be hosted on your WordPress server and not on S3 or Imgix."
],
],
"badPlugins" => [
"MetaSlider" => [
"plugin" => "ml-slider/ml-slider.php",
"description" => "This plugin rolls their own non-standard image resizing functionality which is incompatible with Media Cloud. They should be using WordPress's <code>image_downsize()</code> function."
]
],
"settings" => [
"title" => "Storage Settings",
Expand Down

0 comments on commit 587db56

Please sign in to comment.