Custom Fields
Re-Envisioned
Support General Include Meta Box directly

This topic contains 7 replies, has 2 voices, and was last updated by  Anh Tran 2 years, 3 months ago.

  • Creator
    Topic
  • #5231

    weseo
    Participant

    Hello i have in my WordPress site 2 differnet custom plugins.
    Both Plugins have the meta box libary directly included.

    The first Plugin is a half year old (include a old metabox version) and the second plugin new developed (has the new metabox version included).

    The problem now, wordpress load the plugin with the old metabox version at first.
    So the new second plugin use and load the old metabox version also (but it need the new version).

    How can be avoid this problem?
    I can’t update the metabox in the first old plugin 🙁

    I included the Libary with following tutorial:
    https://metabox.io/docs/include-meta-box-plugin-themes/

    Thank you very much

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #5237

    Anh Tran
    Keymaster

    Hi,

    Currently, our loader mechanism couldn’t detect which version is older and decide to load the newer one :(. It’s probably better to load the plugin from the wordpress.org with the help of TGM Activation class.

    #5248

    weseo
    Participant

    Is it possible to destroy the Metabox Class or add namespaces?
    So that i only use the one metabox libary with is included in the plugin?

    Thank you

    #5253

    Anh Tran
    Keymaster

    You can prevent Meta Box from loading by defining the constant RWMB_VER. Then you might need to manually load the library like this:

    require_once 'path-to-meta-box/inc/loader.php';
    $loader = new RWMB_Loader;
    $loader->init();
    #5267

    weseo
    Participant

    Hello this is my situation:

    Plugin 1 (need Metabox 4.7.1):

    define( 'RWMB_VER', '4.7.1' ); // Example
    require_once 'plugin-1/path-to-meta-box/inc/loader.php';
    $loader = new RWMB_Loader;
    $loader->init();

    Plugin 2 (need Metabox 4.9.8):

    define( 'RWMB_VER', '4.9.8' ); // Example
    require_once 'plugin-2/path-to-meta-box/inc/loader.php';
    $loader = new RWMB_Loader;
    $loader->init();

    But this can not work because the class RWMB_Loader already exists.

    Thank you very much

    #5280

    Anh Tran
    Keymaster

    You can defined the constant RWMB_VER in the wp-config.php file. That makes both plugins won’t load Meta Box.

    Then in the 2nd plugin, where you can edit, add the following lines:

    require_once 'path-to-meta-box/inc/loader.php';
        $loader = new RWMB_Loader;
        $loader->init();
    #5282

    weseo
    Participant

    Ok i understand, but
    Plugin 1 have to load Metabox 4.7.1 and
    Plugin 2 have to load Metabox 4.9.8.

    Plugin 1 is not compatible with Metabox 4.9.8 and
    Plugin 2 is not compatible with Version 4.7.1

    The only possible way is with namespaces or?

    Thank you very much

    #5294

    Anh Tran
    Keymaster

    You can’t load 2 versions of the plugin. The best thing you can do is edit the plugins to compatible with 1 specific version.

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.