Hope you someone help me out here a bit. I'm trying to include a WOT Wrapper (https://github.com/lukaswhite/weboftrust) into a WordPress plugin. However I have no experience whatsoever with PHP namespaces. I'm calling the class from within my plugin file, let's call it plugin.php:
function verify_site_content() {
// Create a client
$client = \Lukaswhite\Weboftrust\WeboftrustClient::factory();
// IMPORTANT - set the API key
$client->setApiKey('xdddxx');
// Call the API, passing in an array of URLs
$response = $client->lookup(array('www.domain.com'));
$website = $response['www.domain.com'];
if ($website->isTrustworthy()) {
// it sure is, do something...
echo "YES TRUSTWORTHY";
} else {
// Uh-oh, perhaps we should be wary of this site.
echo "NO NOT TRUSTWORTHY";
}
//$url = get_site_url();
$url = "http://www.domain.com";
return true;
}
The files are located at:
PLUGINFOLDER
PLUGINFOLDER/plugin.php
PLUGINFOLDER/Lukaswhite/Weboftrust/WeboftrustClient.php etc.
Hope this makes sense. I don't seem to understand why I don't have to include the php files etc. but believe this has to do with namespaces.
Here's the error I'm getting:
Fatal error: Uncaught Error: Class 'Lukaswhite\Weboftrust\WeboftrustClient' not found in /Applications/MAMP/htdocs/abpa11.dev/wp-content/plugins/pluginfolder/plugin.php:137 Stack trace: #0 /Applications/MAMP/htdocs/abpa11.dev/wp-content/plugins/pluginfolder/plugin.php(68): verify_site_content()
Hope one can shed some light...
include
statements. – fuxia♦ Oct 9 '16 at 11:42