TGMPA / TGM-Plugin-Activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
http://tgmpluginactivation.com/
GNU General Public License v2.0
1.75k stars 431 forks source link

How to display notice for required plugins only? #748

Open danyj opened 6 years ago

danyj commented 6 years ago

We have a theme that uses different plugins depending on install. 2 plugins are always required other 5

BudddyPress
bbPress
WooCommerce
LayerSlider
Slider Revolution

are only recommended

How can we display notice only for required plugins?

CreativeDive commented 6 years ago

It's not possible :-)

I've been waiting for a long time for this feature. But unfortunately there are no new releases for a long time by the author. The last one was 2016.

But you can add a workaround with #733

danyj commented 6 years ago

@CreativeDive I saw your post but I would have to list each plugin and we are dealing with framework here and some demos might require different plugin.

has_notices on plugin levels would be favorable

    'bbpress'=> array(
        'name'      => 'bbPress',
        'slug'      => 'bbpress',
        'required'  => false,
        'force_activation'   => false,
                 'has_notices' => false
    ),
danyj commented 6 years ago

And even worse is that the notice is yellow for recommended plugins where in fact should be green because they do not affect the theme functionality.

CreativeDive commented 6 years ago

I'm wondering about envato's decision to treat this plugin as a required plugin for themeforest themes. There are so many issues that make the user experience seem like a nightmare. I also do not understand why there were no new releases in the past.

danyj commented 6 years ago

I also do not understand why there were no new releases in the past.

https://github.com/TGMPA/TGM-Plugin-Activation/issues/741

im digging in to code for has_notices on plugin level , might submit PR

CreativeDive commented 6 years ago

@danyj it's really a nightmare :-(

danyj commented 6 years ago

no is not ,

add here https://github.com/TGMPA/TGM-Plugin-Activation/blob/develop/class-tgm-plugin-activation.php#L1156

            if(isset($plugin['has_notices']) && false === $plugin['has_notices']){

                continue;
            }

in plugin array set

'has_notices' => false

CreativeDive commented 6 years ago

@danyj But it is a nightmare. I need the notice for required plugins only. With 'has_notices' => false notices will never displayed. It's not the solution.

danyj commented 6 years ago

bud , I just showed you how to do it on plugin level , not global

danyj commented 6 years ago

add the code I advised and in your plugin array ( not $config ) set the has_notices like this

    'bbpress'=> array(
        'name'      => 'bbPress',
        'slug'      => 'bbpress',
        'required'  => false,
        'force_activation'   => false,
        'has_notices' => false // This plugin wont be listed in the notice
    ),
CreativeDive commented 6 years ago

@danyj you are fabulous :-) Yes, it does solve one problem, but the user can dismiss this notice for required plugins. He should not.

So i will use a combination of your and my solution #733

Thanks so much!

danyj commented 6 years ago

I would not use this on required plugins , only on recommended

danyj commented 6 years ago

And this does not touch any dismiss settings, it simply removes the plugin from the notice array and if there are no plugins in that array no notice is displayed either way.

CreativeDive commented 6 years ago

@danyj Yes you can use 'force_activation' => true, to activate required plugins after theme activation. Therefore you don't need this notice. But I think it's a user decision to activate plugins. Also the notice should be visible, if the user deactivate a required plugin of a theme.

But the user does not get a notice again if the user has dismissed it in the past.

danyj commented 6 years ago

Also the notice should be visible, if the user deactivate a required plugin of a them

Not sure what you have setup , but here ,

first 3 required , other recommended screenshot_1

Assigned Widgets ( required ) disabled and notice showed up

download

danyj commented 6 years ago

tested dismissable, works as it should

http://take.ms/VmeJQ

CreativeDive commented 6 years ago

@danyj I don't know what is wrong in my file. But if I dismiss the required plugin notice before activating and deactivate the plugin again, I do not get the notice again.

bildschirmfoto 2018-07-08 um 18 32 33
CreativeDive commented 6 years ago

@danyj But I means the "Dismiss this notice" link, not the close button.

bildschirmfoto 2018-07-08 um 18 40 29
danyj commented 6 years ago

I dont see that anymore , http://prntscr.com/k3z1o3

using the actual dev . Watch this please https://github.com/TGMPA/TGM-Plugin-Activation/pull/749

jrfnl commented 6 years ago

But if I dismiss the required plugin notice before activating and deactivate the plugin again, I do not get the notice again.

@CreativeDive This is a known bug - see #353, #482

CreativeDive commented 6 years ago

@danyj I think you can't see it, because you have set 'dismissable' => false, or 'dismissable' => '',

@jrfnl Thanks for the response. Yes I know, it's a bug. But it's not fixed and ready for a new release. Why?

jrfnl commented 6 years ago

@CreativeDive Because it's darn bloody complex to fix. You're welcome to have a go.

CreativeDive commented 6 years ago

@jrfnl If my knowledge were sufficient, I would like to help. But they do not do it. I love ❤️this plugin, but this bug is a nightmare for the user experience. 🤕

Tofandel commented 5 years ago

The recommended plugins shouldn't be green, I think the required should be red and the optionnal yellow..

I just have a question, why would you have suggested plugins in the list if you don't want to show the notice ?

The user cannot install them without the notice so they might as well not be in the list, or do you have your plugin using this array to display recommended plugins somewhere ?

Thanks for the clarification

danyj commented 5 years ago

why would you have suggested plugins i

Recommended and required should not belong to same array. We dont have only recommended ones , if that were the case we would not bother but we have 3 required and depending on demo we have recommended. Recommended do not have to be used for theme to function properly.

The user cannot install them

yes user can still install recommended plugins http://prntscr.com/kddhle

Tofandel commented 5 years ago

Ok thanks for the clarification and forgive my ignorance, I didn't know this menu was here

danyj commented 5 years ago

Don't worry about it, all valid questions. Things is that users HATE the popups , and one theme can recommend 5 so with yellow notice and no distinction between recommended and required users thik this guy wants me to install dozen of plugins for this theme. Hope this makes sense.

Tofandel commented 5 years ago

Ah yeah I got what your saying, I have the same issue indeed, some users think all the recommended plugins are required and install everything, while only one is required, and 2 are recommended

danyj commented 5 years ago

Thus the pull https://github.com/TGMPA/TGM-Plugin-Activation/pulls/danyj