-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- enable Shutterstock parser
- Loading branch information
Showing
4 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* Shutterstock parser | ||
* | ||
* @package parser | ||
* @author Labs64 <[email protected]> | ||
**/ | ||
class CTShutterstock extends CTParser | ||
{ | ||
|
||
const COPYRIGHT = '© %author%/Shutterstock'; | ||
|
||
const BASE_URL = 'http://www.shutterstock.com/pic-'; | ||
|
||
protected function parse($number) | ||
{ | ||
$url = self::BASE_URL . $number; | ||
|
||
$item = parent::parse($number); | ||
$item['source'] = 'Shutterstock'; | ||
$item['publisher'] = 'Shutterstock'; | ||
$item['license'] = 'Royalty-free'; | ||
$item['link'] = $url; | ||
|
||
$doc = new DOMDocument(); | ||
$response = $this->curl($url); | ||
$html = @$doc->loadHTML(wp_remote_retrieve_body($response)); | ||
if ($html) { | ||
$xpath = new DOMXPath($doc); | ||
|
||
$tags = $xpath->query("*/meta[@property='og:url']"); | ||
if (!is_null($tags) && $tags->length > 0) { | ||
$item['link'] = $tags->item(0)->getAttribute('content'); | ||
} | ||
|
||
$tags = $xpath->query("//a[@itemprop='author']"); | ||
if (!is_null($tags) && $tags->length > 0) { | ||
$item['author'] = $tags->item(0)->textContent; | ||
} | ||
} | ||
|
||
return $item; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters