Skip to content

Instantly share code, notes, and snippets.

@seanonthenet
Created March 11, 2016 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanonthenet/af8f8c51193621c75617 to your computer and use it in GitHub Desktop.
Save seanonthenet/af8f8c51193621c75617 to your computer and use it in GitHub Desktop.
/**
* Display recommended plugin notice only on the plugins page, can be dismissed
*/
add_action('admin_notices', 'nikkon_recommended_plugin_notice');
function nikkon_recommended_plugin_notice() {
global $pagenow;
global $current_user;
$user_id = $current_user->ID;
/* If on plugins page, check that the user hasn't already clicked to ignore the message */
if ( $pagenow == 'plugins.php' ) {
if ( ! get_user_meta( $user_id, 'nikkon_recommended_plugin_ignore_notice' ) ) {
echo '<div class="updated plugins-recommended"><p>';
printf( __( '<p class="plugins-recommended-note">Have a look at the <a href="https://kairaweb.com/support/topic/recommended-plugins/" target="_blank">plugins we recommend</a> and install the ones you need to help power your website. <a href="%1$s" class="plugins-recommended-close">X</a></p>', 'nikkon' ), '?nikkon_recommended_plugin_nag_ignore=0' ); ?>
<a href="<?php echo admin_url('plugin-install.php?tab=favorites&user=kaira'); ?>"><?php printf( __( 'SiteOrigin\'s Page Builder & Widgets Bundle', 'nikkon' ), 'nikkon' ); ?></a><br />
<a href="<?php echo admin_url('plugin-install.php?tab=favorites&user=kaira'); ?>"><?php printf( __( 'Meta Slider', 'nikkon' ), 'nikkon' ); ?></a><br />
<a href="<?php echo admin_url('plugin-install.php?tab=favorites&user=kaira'); ?>"><?php printf( __( 'WooCommerce', 'nikkon' ), 'nikkon' ); ?></a><br />
<a href="<?php echo admin_url('plugin-install.php?tab=favorites&user=kaira'); ?>"><?php printf( __( 'Breadcrumb NavXT', 'nikkon' ), 'nikkon' ); ?></a>
<?php
echo "</p></div>";
}
}
}
add_action('admin_init', 'nikkon_recommended_plugin_nag_ignore');
// Dismiss plugin notice
function nikkon_recommended_plugin_nag_ignore() {
global $current_user;
$user_id = $current_user->ID;
/* If user clicks to ignore the notice, add that to their user meta */
if ( isset($_GET['nikkon_recommended_plugin_nag_ignore']) && '0' == $_GET['nikkon_recommended_plugin_nag_ignore'] ) {
add_user_meta( $user_id, 'nikkon_recommended_plugin_ignore_notice', 'true', true );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment