Include Meta Box directly
- This topic has 7 replies, 2 voices, and was last updated 8 years, 8 months ago by
Anh Tran.
-
AuthorPosts
-
March 9, 2017 at 10:55 PM #5231
weseo
ParticipantHello 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
March 10, 2017 at 8:15 AM #5237Anh Tran
KeymasterHi,
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.
March 10, 2017 at 2:56 PM #5248weseo
ParticipantIs 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
March 11, 2017 at 9:06 AM #5253Anh Tran
KeymasterYou 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();March 13, 2017 at 3:43 PM #5267weseo
ParticipantHello 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
March 14, 2017 at 10:46 AM #5280Anh Tran
KeymasterYou can defined the constant
RWMB_VERin thewp-config.phpfile. 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();March 14, 2017 at 2:43 PM #5282weseo
ParticipantOk 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.1The only possible way is with namespaces or?
Thank you very much
March 15, 2017 at 9:06 AM #5294Anh Tran
KeymasterYou can't load 2 versions of the plugin. The best thing you can do is edit the plugins to compatible with 1 specific version.
-
AuthorPosts
- You must be logged in to reply to this topic.