• Resolved EivindFS

    (@eivindfs)


    Hi there,

    I’m doing some admin dashboard configuration of different plugins and need to check if WP-Table reloaded is installed to determine if I should run some code. I’ve tried using function_exists() on several WP-Table reloaded functions and it returns false every time. This works fine on all the other plugins, including cForms and NextGen Gallery, but it doesn’t work for WP-Table for some reason.

    Can anyone tell me how I can test if WP-Table Reloaded is installed or not?

    Thanks,
    Eivind

Viewing 6 replies - 1 through 6 (of 6 total)
  • Leon

    (@leondoornkamp)

    How about:
    if ( class_exists( "CheckPlugin" ) )

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    the function_exists() likely fails, because WP-Table Reloaded has its functions inside classes. So, you will need to use a different syntax.

    It could also be possible that your plugin is run before WP-Table Reloaded has been included. When are you performing the function checks? You should at least wait until the action “plugins_loaded” is fired. Then, you could check for a function inside a class, or (which even works with function_exists(), you can check for the template tag function wp_table_reloaded_print_table().

    The best way, in my opinion, would be to read the array of active plugins from WordPress (a global variable), that way you get a direct list of all activated plugins.

    Best wishes,
    Tobias

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks or the suggestion, Leon. Yes, you could of course simply check for the plugin’s class. However, the same applies: The point of time when you perform the check is important!

    Best wishes,
    Tobias

    Leon

    (@leondoornkamp)

    (double post) because of server timeout

    Thread Starter EivindFS

    (@eivindfs)

    Thank you for the info, Tobias.

    For now, I will go with Leon’s solution which worked beautifully.

    Thanks to the both of you

    Eivind

    Leon

    (@leondoornkamp)

    Well Tobias did have a point.

    You can also do the following:

    add_action( 'plugins_loaded', 'check_plugin' );

    function check_plugin(){
    if ( class_exists( "CheckPlugin" ) ){
    define( 'WP-Table-Active', 'true' );
    }
    }

    and then check

    if( defined( 'WP-Table-Active' ) ) {
    //do actions
    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: WP-Table Reloaded] How can I use code to check if WP-Table is installed?’ is closed to new replies.