• Resolved sagescrub

    (@sagescrub)


    Hello,

    I am looking for a way to determine if a plugin has been disabled for the current page (regardless where it was disabled, on page or post type etc)

    I saw the global option (EOS_xx_Active) in your documentation and that’s not exactly what I am looking for, since the plugin will be disabled in some areas of the site and not others.

    For example, I would like to load a JS script, only if a plugin has not been disabled. Is this possible?

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Thread Starter sagescrub

    (@sagescrub)

    I think I have answered my question. After reviewing carefully and testing the global option EOS_xx_ACTIVE I realize that I had two incorrect assumptions.

    1. If constant EOS_xx_ACTIVE is true, it means it is disabled. I thought that Active means NOT disabled.

    2. I misunderstood how you use the word ‘global’ in the documentation. I thought Global referred to the entire site, not just the current page. I think you mean something else by global.

    Also, a side note: In working through my own troubleshooting I printed out all of the ‘EOS_xx_ACTIVE’ constants. I noticed that some had the boolean value true and some had the value of string ‘true’. So I think it is ok when comparing with == true but not with === true.

    Here is the code I came up with to check if a plugin is disabled on the current page. Please let me know if this is correct usage.

    function freesoul_is_plugin_disabled( $plugin_filename ) {
        if ( ! is_plugin_active( 'freesoul-deactivate-plugins/freesoul-deactivate-plugins.php' ) ) {
            return false;
        }
        
        $constant = 'EOS_' . strtoupper( $plugin_filename ) . '_ACTIVE';
        
        return defined( $constant ) && constant( $constant ) == true;
    }
Viewing 1 replies (of 1 total)

The topic ‘Determin if plugin is loaded’ is closed to new replies.