WebDevStudios / oops-wp

A collection of abstract classes, interfaces, and traits to promote object-oriented programming practices in WordPress.
57 stars 9 forks source link

Wrap example require_once in file_exists() check #30

Closed salcode closed 4 years ago

salcode commented 4 years ago

If the plugin is being loaded as a dependency of something larger (e.g. the project is loading plugins via Composer), the vendor directory may not be local to this plugin. We don't want to throw a fatal error if this is the case, so we check for the existance of the file first.

Fixes #28

jmichaelward commented 4 years ago

@salcode With apologies, I'm going to close this PR without merging. The default scenario as described indicates to run composer require, and then add the require statement from that relative directory - it makes no suggestion or recommendation for that require statement to be local to a plugin or theme itself.

Although it's certainly true that there are situations where the default example may not apply, and it is generally good, standard practice to run a file_exists check before requiring an asset (I prefer is_readable, myself), I feel that clarifying these details as being outside of the scope of this library's README file.