sumitpore / mvc-plugin-boilerplate-for-wordpress

An MVC WordPress Plugin Boilerplate with clear separation of concerns. Will make your experience of creating a WordPress Plugin enjoyable!
176 stars 22 forks source link

Separate File to define requirements of the plugin #20

Closed sumitpore closed 5 years ago

sumitpore commented 5 years ago

Plugins can have specific requirements of

In a traditional way, we can add them in the main php file and then write code to check if those requirements are being met or not.

Plugin Boilerplate already supports min PHP Version & WP Version requirement feature. It does not have a dependent plugins requirement feature right now. Of course code this feature can be added in the main plugin's file but that is like adding noise in the main file. The part of checking whether requirements are being fulfilled or not should be handled by a separate class.

sumitpore commented 5 years ago

Commits 5a860de7fc4189914d4a675ee401c60f7194fa49, 658d5206c2b672f532100c41d0a7f38458d00e6b & bf8a34825d5290e049fe617d8bc3195c19ccdd7d handle this.

The configuration for the plugin can be defined in requirements-config.php file.

Sample config could look like this


<?php
return [

    'min_php_version' => '5.6', // Minimum PHP Version.

    'min_wp_version' => '4.8',  // Minimum WordPress Version.

    'is_multisite_compatible' => false, // True if our plugin is Multisite Compatible.

    'required_plugins' => [ // Plugins on which our plugin is dependent on.

        'Hello Dolly' => [
            'plugin_slug' => 'hello-dolly/hello.php',
            'min_plugin_version' => '1.5',
        ],

    ],

];