You can use this script to achieve your answers of course you have to modify the css part and few here and there. 🙂
I am removing message if user clicks on Hide Notice
link (or close button after css) if you don’t want this functionality then remove the current_user click detection part also you have to add js to remove the message if user clicks on Hide Notice
.
Also I am using class_exist
to check, whether plugin is installed or not (hack), you can use is_plugin_active to detect.
I hope you get the idea.
Happy coding
if ( ! class_exists('fakerpress/fakerpress.php') && current_user_can( 'manage_options' ) ) {
add_action('admin_notices', 'plugin_required_admin_notice');
function plugin_required_admin_notice() {
global $current_user ;
$user_id = $current_user->ID;
if ( ! get_user_meta($user_id, 'plugin_required_ignore_notice') ) {
echo '<div class="updated"><p>';
printf(__('This theme recommends the following plugins: <a href="https://wordpress.stackexchange.com/questions/204497/%1$s">FakerPress</a> | <a href="https://wordpress.stackexchange.com/questions/204497/%1$s">Hide Notice</a>'), '?plugin_required_nag_ignore=0');
echo "</p></div>";
}
}
add_action('admin_init', 'plugin_required_nag_ignore');
function plugin_required_nag_ignore() {
global $current_user;
$user_id = $current_user->ID;
if ( isset($_GET['plugin_required_nag_ignore']) && '0' == $_GET['plugin_required_nag_ignore'] ) {
add_user_meta($user_id, 'plugin_required_ignore_notice', 'true', true);
}
}
}