Skip to content

Instantly share code, notes, and snippets.

@mihdan
Forked from johnregan3/amp-check-for-plugin.php
Created September 28, 2016 16:04
Show Gist options
  • Select an option

  • Save mihdan/ea21383c0d7298d294c225568e5e9148 to your computer and use it in GitHub Desktop.

Select an option

Save mihdan/ea21383c0d7298d294c225568e5e9148 to your computer and use it in GitHub Desktop.
Admin notice if the WP AMP Plugin is not installed.
<?php
/**
* Show an Admin Notice if the AMP plugin is not found.
*
* This is a basic implementation. Naturally, you'll want
* to add ajax support so that once this is dismissed, it goes
* away permanently. Also, you may want to limit the admin
* pages this displays to prevent annoying your users.
*
* @return bool
*/
function jr3_amp_is_active() {
if ( is_plugin_active( 'amp/amp.php' ) ) {
return false;
}
?>
<div class="notice notice-error is-dismissible">
<p>
<a href="https://wordpress.org/plugins/amp/" target="_blank"><?php esc_html_e( 'The AMP plugin by Automattic', 'jr3-amp-tutorial' ); ?></a>&nbsp;<?php esc_html_e( 'is not installed or activated.', 'jr3-amp-tutorial' ); ?>
</p>
</div>
<?php
}
add_action( 'admin_notices', 'jr3_amp_is_active' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment