Skip to content

Commit

Permalink
Added option to define contextualUrls within widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
sulfo committed Feb 13, 2018
1 parent dd23937 commit 98b7993
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,5 +299,9 @@ wp_cxense()->get_widget_documents([
],
...
],
'contextualUrls' => [
0 => 'https://articleNotToBeIncludedInResults.com',
...
],
]);
```
17 changes: 16 additions & 1 deletion src/Bonnier/WP/Cxense/Services/WidgetDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ public static function set_arrayInput(array $arrInput)
*/
public function get_documents()
{
$objDocuments = isset($this->set_categories()->set_parameters()->set_user()->get()->items) ? $this->set_categories()->set_parameters()->set_user()->get()->items : [];
$objDocuments = isset($this->set_categories()->set_parameters()->set_contextualUrls()->set_user()->get()->items)
? $this->set_categories()->set_parameters()->set_contextualUrls()->set_user()->get()->items
: [];

return [
'totalCount' => count($objDocuments),
Expand Down Expand Up @@ -185,6 +187,19 @@ private function set_parameters()
return $this;
}

/**
* Set contextualUrls array to the request payload
*
* @return WidgetDocument
*/
private function set_contextualUrls()
{
if (isset($this->arrInput['contextualUrls']) && is_array($this->arrInput['contextualUrls'])) {
$this->arrPayload['context']['contextualUrls'] = $this->arrInput['contextualUrls'];
}
return $this;
}

/**
* Set user array to the request payload
*
Expand Down
2 changes: 1 addition & 1 deletion wp-cxense.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: WP cXense
* Version: 1.2.8
* Version: 1.2.9
* Plugin URI: https://github.com/BenjaminMedia/wp-cxense
* Description: This plugin integrates your site with cXense by adding meta tags and calling the cXense api
* Author: Bonnier - Alf Henderson
Expand Down

0 comments on commit 98b7993

Please sign in to comment.