Skip to content

Instantly share code, notes, and snippets.

@ideadude
Created December 6, 2018 21:46
Show Gist options
  • Save ideadude/37fa9dd0d3d97b5af6aab6d3300ff523 to your computer and use it in GitHub Desktop.
Save ideadude/37fa9dd0d3d97b5af6aab6d3300ff523 to your computer and use it in GitHub Desktop.
A general purpose check for deprecated add ons.
/**
* Check for merged plugins that should be deactivated.
*/
function pmpro_check_for_deprecated_plugins() {
$pmpro_deprecated_plugins = array(
'pmpro-better-logins-report/pmpro-better-logins-report.php' => 'Better Logins Report',
);
$plugins_to_deactivate = array();
foreach( $pmpro_deprecated_plugins as $plugin_path => $plugin_name ) {
if ( is_plugin_active( $plugin_path ) ) {
$plugins_to_deactivate[$plugin_path] = $plugin_name;
}
}
if ( ! empty( $plugins_to_deactivate ) ) {
?>
<div id="message" class="updated notice error is-dismissible">
<p>
<?php
echo __('The following plugins have been merged into the Paid Memberships Pro core plugin and should be deactivated:', 'paid-memberships-pro' );
?>
</p>
<ul>
<?php foreach( $plugins_to_deactivate as $plugin_path => $plugin_name ) { ?>
<li>
<?php echo $plugin_name; ?> (<a href="#"><?php _e( 'Deactivate', 'paid-memberships-pro' ); ?></a>)
</li>
<?php } ?>
</ul>
</div>
<?php
}
}
add_action( 'admin_notices', 'pmpro_check_for_deprecated_plugins' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment