How to provide a plugin which requires CMB2 (plugin dependencies)?

Every serious plugin developer probably has to deal with this problem: WordPress is not supporting composer or any dependency management by default. I have written a great plugin which I would like to put into the official repository on WordPress.org.

Problem is: I do not want to write all of those options pages (including network options pages) on my own - this is why I am using the CMB2 library. It is actually a well known framework used by a lot of WordPress developers in order to create options pages: https://github.com/CMB2/CMB2

Most probably it is not a good idea to put the CMB2 library into my Plugin (which would also require constant updates). But what other option do I have? What is a good way to deal with this problem?

Topic composer wp-dependencies library wp-admin plugins Wordpress

Category Web


On your plugin activation hook method you can check if CMB plugin is installed and/or activated.

You can check this using the following methods:

  1. is_plugin_active(): only available from within the admin pages
  2. function_exists() or class_exists(): available anywhere once they are PHP core methods

If CMB is not installed, you can throw an error message in the panel with instructions to the user on how to install it.

This article has a great explanation on how to check WordPress Plugin Dependencies.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.