Support Forum

is_plugin_active error

RB rb22
rb22
Member

I see this is being discussed again … in relation to a post by Robert V.

To review what I said previously see here:

https://simple-press.com/support-forum/sp5-general-topics/wp-undefined-function-error/

Like Robert, I too just notice this error today on the forum admin profiles page.

Fatal error: Call to undefined function is_plugin_active() in /home/XXXXX/public_html/XXXX/wp-content/plugins/simple-press/admin/panel-profiles/forms/spa-profiles-options-form.php on line 71

However, if I insert

 include_once(ABSPATH.’wp-admin/includes/plugin.php’);

into sp-load-admin.php

I don’t get the error.

I was on this profile admin page because I was trying to set the profile display mode to use buddypress the buddypress member profile. I was puzzled because I had done a virgin in stall of wp/sp/buddypress to see if I got the is_plugin_active error and I did not. Therefore I thought something was wrong with my normal installation.

However, now I think that in fact is_plugin_active is not visible to simple-press. If I insert the function is_plugin_active into a random simple press file that is not subject to if/then conditions, I get the error. 

I think the reason you/I were not getting the error on test installations was because you/I weren’t using mode = 3 …. i.e.  for buddypress/mingle profiles.

you can test whether is_plugin_active is visible regardless of the mode by inserting

echo is_plugin_active(‘buddypress/bp-loader.php’);

above

    if (($mode == 3 && !is_plugin_active(‘buddypress/bp-loader.php’)) || ($mode == 6 && !is_plugin_active(‘mingle/mingle.php’))) {
        $mode = 1;
    }

in the file:

sp-api/sp-api-common-display.php

(I think you’ll get the error.)

I also did not get the error on the virgin install initially because I had no forums posts and thus not user profile link would be displayed and therefore the offending function would not be called.

Finally, it further seems that is_plugin_active is not supposed to be visible. Perhaps wp increased security recently?

https://codex.wordpress.org/Function_Reference/is_plugin_active

“NOTE: defined in wp-admin/includes/plugin.php, so this is only available from within the admin pages, and any references to this function must be hooked to admin_init or a later action. If you want to use this function from within a template, you will need to manually require plugin.php, an example is below. “

6 Answers

New Answer

MP Mr Papa
Mr Papa
Member

quite strange… and not sure why it wouldnt be more widespread as we have many users (including our tests) that would hit the code you mention…

but the wp docs you link to is pretty clear…  thanks for that info…

will open a ticket and do some testing…  and see if we need to get a fix in place (the docs do indicate we do)…  and since we use that function elsewhere too, will check those…

MP Mr Papa
Mr Papa
Member

okay, so have fixed this up for the next version – thanks for the great help!

you of course already have a fix in place, but for those that may find this, in sp-api-common-display, php, around line 309 (will vary by version), find

    if (($mode == 3 && !is_plugin_active('buddypress/bp-loader.php')) || ($mode == 6 && !is_plugin_active('mingle/mingle.php'))) {

and change it to

    include_once(ABSPATH.'wp-admin/includes/plugin.php');
    if (($mode == 3 && !is_plugin_active('buddypress/bp-loader.php')) || ($mode == 6 && !is_plugin_active('mingle/mingle.php'))) {

thanks again….

RB rb22
rb22
Member

Cool. As always you guys are quick to resolve issues. Thanks for the feedback.

YS Yellow Swordfish
Yellow Swordfish
Member

With thanks from us to the people who helped us resolve things…