-
-
Save broskees/acf8c2c23622c660a3c1f5fd24ae6619 to your computer and use it in GitHub Desktop.
WordPress mu plugins to check if "Advanced Custom Fields Pro" is active.
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('plugins_loaded', function() { | |
if ( !function_exists('is_plugin_active') ) { | |
/** WordPress Plugin Administration API */ | |
require_once(ABSPATH . 'wp-admin/includes/plugin.php'); | |
} | |
if ( is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) ) { | |
return; | |
} | |
$tp_acf_notice_msg = __( 'This website needs "Advanced Custom Fields Pro" to run. Please download and activate it', 'tp-notice-acf' ); | |
/* | |
* Admin notice | |
*/ | |
add_action( 'admin_notices', function () use ($tp_acf_notice_msg) { | |
echo sprintf('<div class="notice notice-error notice-large"><div class="notice-title">%s</div></div>', $tp_acf_notice_msg); | |
} ); | |
/* | |
* Frontend notice | |
*/ | |
add_action( 'template_redirect', function () use ($tp_acf_notice_msg) { | |
wp_die( $tp_acf_notice_msg ); | |
}, 0 ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment