You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This plugin enables your WordPress site to integrate with cXense.
It adds the meta tags and scripts needed by cXense in order to scan your site.
It also calls cXense whenever you make changes to your content.
Finally it adds the possibility to save a cXense recommendation widget per content type and provides hooks to call them in your view/theme.
Requirements
WordPress 4.3 or higher
Language support (Optional) Polylang plugin must installed and activated version 1.8.4 or higher
Once you have installed and activated the plugin then make sure that you have
a set of api credentials for the cXense API.
Once you have your credentials you may go to the settings page labeled cXense.
Here you must enter your cXense Site ID, cXense API user,
cXense API key and finally your cXense Organisation prefix.
Remember the plugin will not work until you check the Enable switch in the settings page
Widgets
The plugin will generate a CX Widget ID settings field for each post type
you have available on your WordPress Installation. Here you must enter the
cXense recommendation widget ID that you would like represented on your
content type.
For debug purpose you can enable or disable the query cache. It is recommended to be enabled in production.
SortBy Widget ID will be only used for widgets sortby options in wp-base.
Rendering widgets
In order to render the widgets available for your post you should make sure
that you have filled out the CX widget ID field in the plugin settings
page.
When rendering the widgets the plugin provides you with two options:
Let cXense render the HTML of the widgets
Get the data and for the widget and build the HMTL yourself
Once you have picked the method you want to use you should go to the theme file
that represents the single view of your post_type from this file you may call the
following methods to get the widget data:
Let cXense render the HTML of the widgets
WpCxense::instance()->render_widget();
The sample output of this function could look like:
Searching documents will return an object of the following format:
array (size=2)
0 =>
object(stdClass)[538]
public 'buckets' =>
array (size=6)
...
1 =>
object(stdClass)[542]
public 'buckets' =>
array (size=3)
...
public 'totalCount' => int 79
public 'matches' =>
array (size=10)
0 =>
object(Bonnier\WP\Cxense\Parsers\Document)[521]
public 'id' => string '551790ba522b4b9427ca947e1b3353e137d78a85' (length=40)
public 'siteId' => string '1129402680464567580' (length=19)
public 'score' => float 2.0455377
public 'fields' =>
array (size=10)
...
public 'highlights' =>
array (size=1)
...
public 'spellcheck' =>
array (size=1)
0 =>
object(stdClass)[663]
public 'term' => string 'mor' (length=3)
public 'suggestions' =>
array (size=0)
...">object(stdClass)[543] public 'facets' => array (size=2) 0 => object(stdClass)[538] public 'buckets' => array (size=6) ... 1 => object(stdClass)[542] public 'buckets' => array (size=3) ... public 'totalCount' => int 79 public 'matches' => array (size=10) 0 => object(Bonnier\WP\Cxense\Parsers\Document)[521] public 'id' => string '551790ba522b4b9427ca947e1b3353e137d78a85' (length=40) public 'siteId' => string '1129402680464567580' (length=19) public 'score' => float 2.0455377 public 'fields' => array (size=10) ... public 'highlights' => array (size=1) ... public 'spellcheck' => array (size=1) 0 => object(stdClass)[663] public 'term' => string 'mor' (length=3) public 'suggestions' => array (size=0) ...
The 'matches' key contains an array of objects that have the 'fields' value accessible directly through the magic method __get(). This means that you can call any field from the 'fields' with the direct pointer:
$objResults->matches[0]->author;
A complete document result looks like:
string '551790ba522b4b9427ca947e1b3353e137d78a85' (length=40)
public 'siteId' => string '1129402680464567580' (length=19)
public 'score' => float 0.40566906
public 'fields' =>
array (size=9)
0 =>
object(stdClass)[715]
public 'field' => string 'author' (length=6)
public 'value' => string 'i form' (length=6)
1 =>
object(stdClass)[718]
public 'field' => string 'bod-cat' (length=7)
public 'value' => string 'Sund graviditet' (length=15)
2 =>
object(stdClass)[719]
public 'field' => string 'bod-cat-top' (length=11)
public 'value' => string 'Sundhed' (length=7)
3 =>
object(stdClass)[720]
public 'field' => string 'bod-cat-url' (length=11)
public 'value' => string 'http://iform.dk/sundhed/sund-graviditet' (length=39)
4 =>
object(stdClass)[721]
public 'field' => string 'bod-pagetype' (length=12)
public 'value' => string 'article' (length=7)
5 =>
object(stdClass)[722]
public 'field' => string 'description' (length=11)
public 'value' => string 'Gar du med babytanker, har du en fordel, hvis du bor taet pa din mor.' (length=71)
6 =>
object(stdClass)[723]
public 'field' => string 'recs-publishtime' (length=16)
public 'value' => string '2015-04-19T22:00:00.000Z' (length=24)
7 =>
object(stdClass)[724]
public 'field' => string 'title' (length=5)
public 'value' => string 'Din mor oger dine baby-chancer' (length=31)
8 =>
object(stdClass)[725]
public 'field' => string 'url' (length=3)
public 'value' => string 'http://iform.dk/sundhed/sund-graviditet/din-mor-kan-hjaelpe -til-familieforoegelsen' (length=82)">object(Bonnier\WP\Cxense\Parsers\Document)[710] public 'id' => string '551790ba522b4b9427ca947e1b3353e137d78a85' (length=40) public 'siteId' => string '1129402680464567580' (length=19) public 'score' => float 0.40566906 public 'fields' => array (size=9) 0 => object(stdClass)[715] public 'field' => string 'author' (length=6) public 'value' => string 'i form' (length=6) 1 => object(stdClass)[718] public 'field' => string 'bod-cat' (length=7) public 'value' => string 'Sund graviditet' (length=15) 2 => object(stdClass)[719] public 'field' => string 'bod-cat-top' (length=11) public 'value' => string 'Sundhed' (length=7) 3 => object(stdClass)[720] public 'field' => string 'bod-cat-url' (length=11) public 'value' => string 'http://iform.dk/sundhed/sund-graviditet' (length=39) 4 => object(stdClass)[721] public 'field' => string 'bod-pagetype' (length=12) public 'value' => string 'article' (length=7) 5 => object(stdClass)[722] public 'field' => string 'description' (length=11) public 'value' => string 'Gar du med babytanker, har du en fordel, hvis du bor taet pa din mor.' (length=71) 6 => object(stdClass)[723] public 'field' => string 'recs-publishtime' (length=16) public 'value' => string '2015-04-19T22:00:00.000Z' (length=24) 7 => object(stdClass)[724] public 'field' => string 'title' (length=5) public 'value' => string 'Din mor oger dine baby-chancer' (length=31) 8 => object(stdClass)[725] public 'field' => string 'url' (length=3) public 'value' => string 'http://iform.dk/sundhed/sund-graviditet/din-mor-kan-hjaelpe-til-familieforoegelsen' (length=82)
Widget documents
If the key 'widget_id' is missing from the input array then a WidgetMissingId exception is thrown.