Skip to content

Instantly share code, notes, and snippets.

@johnregan3
Last active September 28, 2016 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnregan3/7fb06e7413bc8bb40a39f6d4027c4ca1 to your computer and use it in GitHub Desktop.
Save johnregan3/7fb06e7413bc8bb40a39f6d4027c4ca1 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