• Resolved Jake Bresnehan

    (@jakebresnehan)


    Hey Everyone,

    I new to the plugin development game and am seeking some advice on how to avoid a conflict with two plugin’s using the same API.

    I am using the Campaign Monitor API wrapper in my plugin but it seems that another plugin I have installed is also. That plugin is using an older version of the API so I am keen work out how I can force my plugin to use my API wrapper.

    The error:
    Fatal error: Cannot redeclare CS_REST_SERIALISATION_get_available() (previously declared in

    I have tried renaming the directory where my wrapper is located, but that doesn’t seem to do the trick.

    Any advice would be greatly appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You need to first check to see if the Campaign Monitor API class exists. You can do this with a simple IF check:

    if( ! class_exists( 'CS_REST_Clients' ) )
    	require_once('vendor/csrest_clients.php');

    This makes it so your class is only included if it doesn’t already exist via another plugin.

    Thread Starter Jake Bresnehan

    (@jakebresnehan)

    Cheers Pippin.

    That is exactly the problem. Rookie mistake.

    Also I am not sure if there is a way around this, but if you have two plugins using the same wrapper but one is older, is there any way of using the newer wrapper?

    e.g.

    Plugin 1 – Ajax CM uses version 1.0.3 of the wrapper
    Plugin 2 – CM Dashboard uses version 3.1.0 of the wrapper

    Plugin 1 seems to be getting loaded first because of the name (alphabetical ordered) and uses version 1.0.3 of the wrapper and plugin 2 doesn’t load the wrapper because it’s already loaded but uses version 3.1.0 of the wrapper.

    Cheers,
    Jake

    It depends on how the wrapper is built. if it includes a version number that you can read, you might be able to use that.

    Thread Starter Jake Bresnehan

    (@jakebresnehan)

    It sure does.

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Conflicting API's in Plugin’ is closed to new replies.