简体   繁体   中英

Integrating External Library into Wordpress

I'm trying to bring in an outside PHP library into my WP instance. I'd like to reference it in various plugins I'm creating, but am not sure how to include or instantiate it.

Specifically, I'm looking at the Library here: https://github.com/lobostome/FurryBear/wiki

I've tried a few different ways to include it without success, including using the SPLClassLoader command described here: https://github.com/lobostome/FurryBear/wiki/Installation

I'm not sure where to put the full library and then how to get it recognized by / loaded into WordPress so that it can be used.

Any help would be appreciated. Thanks

if your writing your own plugin you can put the FurryBear code in your plugin folder and then include it manually like

require_once 'SplClassLoader.php';

// Instantiate the SplClassLoader with the location directory of the source files.
$classLoader = new SplClassLoader(__DIR__ . '/src');
$classLoader->register();

Thanks. Basically, the require_once call to SplClassLoader.php they give on the wiki, and you mention above, is how it should be done. The problem was that the files were buried deep within the default build and were meant to be referenced from the same top level directory.

I moved the SplClassLoader.php file out as well as the src folder, putting both in the top level plugins folder and all worked as expected.

Thanks again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM