$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) { /* 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', 'Callback' => 'alx_process_editorial', 'Default' => '-', 'Live' => '1', 'Position' => array(array('EditorialReviews','EditorialReview')) ); return $keywords; } /* * Filter to add extra default templates */ function alx_add_editorial_templates ($templates) { $templates['editorial'] = array( 'Name' => __('Editorial','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_action( 'amazon_link_pre_init', 'alx_editorial_install' ); function alx_editorial_install() { add_filter('amazon_link_keywords', 'alx_add_editorial'); add_filter('amazon_link_default_templates', 'alx_add_editorial_templates'); } ?>