Skip to content

Instantly share code, notes, and snippets.

@broskees
Forked from freezvd/acf-missing.php
Last active June 2, 2022 20:18
Show Gist options
  • Save broskees/acf8c2c23622c660a3c1f5fd24ae6619 to your computer and use it in GitHub Desktop.
Save broskees/acf8c2c23622c660a3c1f5fd24ae6619 to your computer and use it in GitHub Desktop.
WordPress mu plugins to check if "Advanced Custom Fields Pro" is active.
<?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