Created
June 25, 2016 04:56
-
-
Save jrobinsonc/7ebcbb34c2f91ecdd534bee5c07bb574 to your computer and use it in GitHub Desktop.
WordPress: Required plugins hook.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('admin_notices', function() | |
{ | |
$plugin_messages = array(); | |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
$required_plugins = [ | |
'wordpress-seo/wp-seo.php' => 'Yoast SEO', | |
'sendgrid-email-delivery-simplified/wpsendgrid.php' => 'SendGrid', | |
'w3-total-cache/w3-total-cache.php' => 'W3 Total Cache', | |
'woocommerce/woocommerce.php' => 'W3 Total Cache', | |
]; | |
foreach ($required_plugins as $plugin_slug => $plugin_label) | |
{ | |
if(!is_plugin_active($plugin_slug)) | |
{ | |
$plugin_messages[] = "Activate plugin: {$plugin_label}."; | |
} | |
} | |
if(count($plugin_messages) > 0) | |
{ | |
echo '<div id="message" class="error">'; | |
foreach($plugin_messages as $message) | |
{ | |
echo '<p><strong>'.$message.'</strong></p>'; | |
} | |
echo '</div>'; | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment