Using WordPress gettext functions in a library outside plugin or theme scope

WordPress doesn’t quite have a practice of localizing something that isn’t core/plugin/theme. My educated guess would be that it will work just fine with same concepts, but you will have to write custom loading logic. Use lower level load_textdomain(), since higher level functions are meant for plugins/themes specifically. As long as you determine and load … Read more

How to add in my plugin a third vendor Git project with composer.json

Composer generates the autoloader for you. Thus, you don’t need to require a specific file from vendor packages. All you need to do is require the composer autoloader: Change require_once dirname(__FILE__) . ‘/vendor/Frozensheep/RightmoveADF/RightmoveADF.php’; to require_once plugin_dir_path(__FILE__) . ‘vendor/autoload.php’; In some cases, classes still not be found. Re-generate the composer autoloader by $ composer dump-autoload. Usually, … Read more

Ran into a problem installing plugins with Composer

In order for WordPress to recognize a plugin it needs to be in the correct plugins folder. In an usual installation this is wp-content/plugins/ If you use wpackagist.org, a working example would be this composer.json: { “repositories”: [ { “type”: “composer”, “url”: “https://wpackagist.org” } ], “require”: { “wpackagist-plugin/broken-link-checker”: “*”, “wpackagist-theme/twentyseventeen”: “*” } } wpackagist-plugin signals … Read more

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

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: is_plugin_active(): only available from within the admin pages 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 … Read more

Deploying WordPress with Composer

You can do whatever suits your needs, such as still using composer but configuring your implementation to place the directories back into the root along with core, however the primary purpose in having core stand-alone from other directories is for separation of concerns that are not dependant upon one another sharing the same path. The … Read more