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.76k stars 431 forks source link

Envato Theme Check Error: is_plugin_active() is not reliable. Use function_exists() or class_exists() instead. #737

Closed stalukder03 closed 6 years ago

stalukder03 commented 6 years ago

Hi Author,

I have developed a WP theme using this "tgmpa" for themeforest. I have used this tgmpa code with a file in theme directory and include this in functions.php file.

TF reviewer have provided a soft rejection with few issues. One of the issue is

REQUIRED: _Found is_plugin_active( in the file lib/theme-config/config-tgm/_class-tgm-plugin-activation.php. is_plugin_active() is not reliable. Use function_exists() or classexists() instead.

In that case what should i do? Please provide a solution. I would be glad and grateful.

Best Regards, Sajib Talukder

dingo-d commented 6 years ago

Tell him that this is not an issue since TGMPA is only used on the admin, and is_plugin_active() works only on admin. Plus they shouldn't be looking at TGMPA at all. Explain to him what this is, and why it can be ignored safely.

jrfnl commented 6 years ago

@stalukder Please tell the Themeforest theme reviewer to contact @Stephen-Cronin . TGMPA is officially allowed by TF as-is as long as you use the TF version, so it should not be (soft) rejected.

REQUIRED: _Found is_plugin_active( in the file lib/theme-config/config-tgm/class-tgm-plugin-activation.php. is_plugin_active() is not reliable. Use function_exists() or class_exists() instead.

While that is of course completely true (actually reads like something I could have written), TGMPA generally does not know function/class names of the plugins you need, so cannot check for those. If you like, you could (optionally) pass those via the configuration if you do know them and TGMPA will actually execute such a check in that case.


@dingo-d Nice, we were responding simultaneously ;-)

stalukder03 commented 6 years ago

@dingo-d & @jrfnl Thank you guys. :)

CreativeDive commented 6 years ago

Some envato reviewer do not know what they are talking about.

Stephen-Cronin commented 6 years ago

Thanks for the ping @jrfnl

We have a requirement around not using is_plugin_active, but we hadn't considered the TGM PA use case. Makes sense for us to allow that, so we'll make that an exception and get our requirements etc sorted out to reflect that.

@stalukder In the meantime, if you resubmit the theme, please link them to this issue in the Notes and ask them to check with me. Thanks and sorry for the confusion.

Stephen-Cronin commented 6 years ago

Just to follow up, we've added a clause to our requirements exempting TGM Plugin Activation (when generated using the ThemeForest option) and changed our Theme Check fork so this shouldn't be reported.

@stalukder It would still be worth linking to this issue when resubmitting. Thanks!

jrfnl commented 6 years ago

As this has now been resolved on the TF end, I'm closing this issue.

mdsalam2021 commented 5 years ago

Use just use class_exists opposite of is_plugin_active . Then hope your problem will be solve.

Mamtrs commented 5 years ago

Envato Theme Check still returns following errors and reviewer said:

All Authors need to ensure any issues that result in a REQUIRED notice in the Envato Theme Check plugin [ https://github.com/envato/Envato-Theme-Check ] are resolved. There are no longer any allowable exceptions.

WARNING: Found remove_filter( in the file classTgmPluginActivation.php. Themes should not remove core filters. Ensure this is a valid use case.

Line 894: remove_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_sou
Line 2980: remove_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adj
Line 3414: /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin
Line 3417: remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10
Line 3442: remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10

REQUIRED: Found is_plugin_active( in the file classTgmPluginActivation.php. is_plugin_active() is not reliable. Use function_exists() or class_exists() instead.

Line 901: if ( $this->is_automatic && ! $this->is_plugin_active( $slug ) ) {
Line 1061: } elseif ( $this->is_plugin_active( $slug ) ) {
Line 1122: if ( $this->is_plugin_active( $slug ) && false === $this->does_plugin_have_update( $slu
Line 1140: if ( ! $this->is_plugin_active( $slug ) && $this->can_plugin_activate( $slug ) ) {
Line 1796: if ( ! $this->is_plugin_active( $slug ) || false !== $this->does_plugin_have_update( $slu
Line 1827: public function is_plugin_active( $slug ) {
Line 1828: return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) );
Line 1883: return ( ! $this->is_plugin_active( $slug ) && ! $this->does_plugin_require_update( $slug ) )
Line 2046: if ( true === $plugin['force_deactivation'] && is_plugin_active( $plugin['file_path'] ) ) {
Line 2312: if ( $this->tgmpa->is_plugin_active( $slug ) && false === $this->tgmpa->does_plugin_have_updat
Line 2403: if ( ! $this->tgmpa->is_plugin_active( $slug ) ) {
Line 3331: $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) );
Line 3360: $this->skin->plugin_active = is_plugin_active($plugin);
Line 3467: if ( ! is_plugin_active( $plugin_info ) ) {
jrfnl commented 5 years ago

@Stephen-Cronin :point_up:

Stephen-Cronin commented 5 years ago

@Mamtrs - I believe this is because you have renamed class-tgm-plugin-activation.php to classTgmPluginActivation.php. If you change it back, Envato Theme Check will recognise it and ignore the issues (as TGM PA is exempt from our guidelines).

Perhaps we should have a more robust way of recognising the TGM PA file, but that's what we've got for the moment.