$items);
}
$unique_items = array();
$primary = key($elements);
$result = '';
foreach ($items as $item) {
if (isset($item[$primary]) && ($preserve_duplicates || !in_array($item[$primary], $unique_items))) {
$unique_items[] = $item[$primary];
foreach($elements as $element => $info) {
$result .= $info['Pre'] . $item[$element] . $info['Post'];
}
}
}
return $result;
}
/*
* Filter to process the raw editorial content AWS data
*/
function alx_process_editorial ($editorial, $keyword_info, $al) {
/* Only process if it is an array, if it isn't then it probably has already been filtered. */
if (is_array($editorial)) {
return alx_merge_items($editorial, array('Source' => array('Pre' => '
',
'Post' => '
'),
'Content' => array('Pre' => '',
'Post' =>'
')));
} else {
return $editorial;
}
}
/*
* Filter to add the 'Editorial' keyword and attach a filter to it to grab the content
*/
function alx_add_editorial ($keywords) {
$keywords['Editorial'] = array( 'Description' => __('Editorial Reviews (non-copyrighted only)', 'amazon-link'),
'Group' => 'EditorialReview',
'Filter' => 'amazon_link_editorial',
'Default' => '-',
'Live' => '1',
'Position' => array(array('EditorialReviews','EditorialReview')) );
return $keywords;
}
/*
* Filter to add extra default templates
*/
function alx_add_templates ($templates) {
$templates['Editorial'] = array( 'Name' => __('Editorial Reviews','amazon-link'),
'Description' => __('Editorial Reviews (non-copyrighted only)', 'amazon-link'),
'Content' => htmlspecialchars('%EDITORIAL%US#
'),
'Version' => '1',
'Notice' => 'New Template',
'Type' => 'Product',
'Preview_Off' => 0 );
return $templates;
}
/*
* Install the editorial content keyword, data filters and template
*/
add_filter('amazon_link_editorial', 'alx_process_editorial', 1,3);
add_filter('amazon_link_keywords', 'alx_add_editorial');
add_filter('amazon_link_default_templates', 'alx_add_templates');
?>