here to quickly add multiple new store pages. To display a store in a page or post: [amazon trackingid="YOUR-CAMPAIGN-ID" keywords="YOUR-STORE-KEYWORDS" rows="NUMBER-OF-ROWS-YOU-WANT-TO-DISPLAY" columns="NUMBER-OF-COLUMNS-YOU-WANT-TO-DISPLAY" pagination="yes" vertical="yes"] Use spaces between the keywords. You can also display the store as a widget.
Author: GeekLad
Version: 1.1
Author URI: http://geeklad.com/
License: GPL
*/
/* Copyright 2009 GeekLad (email : geeklad@geeklad.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
add_shortcode('amazon', 'amazon_store_display');
function amazon_store_display($atts) {
extract(shortcode_atts(array(
'trackingid' => false,
'keywords' => false,
'rows' => '5',
'columns' => '2',
'pagination' => false,
'customcss' => false,
'logo' => 'white',
), $atts));
if (!$keywords || !$trackingid)
return "";
if ($pagination && $pagination != "none") {
$pagination = "&pagination=yes";
if ($_GET['pagenumber'])
$pagination .= "&pagenumber=" . $_GET['pagenumber'];
else
$pagination .= "&pagenumber=1";
}
if ($customcss && $customcss != "none")
$customcss = "&customcss=sidebar";
$logo = "&logo=" . $logo;
$keywords = urlencode($keywords);
$storeurl = "http://geeklad.com/tools/amazon/amazon.php?trackingid=$trackingid&rows=$rows&columns=$columns$pagination$customcss$logo&keyword=$keywords";
return file_get_contents($storeurl);
}
add_action("plugins_loaded", "amazon_store_widget_init");
function amazon_store_widget_init() {
wp_register_widget_control("free_amazon_store_widget", __('Amazon Niche Store'), 'amazon_store_widget_control');
wp_register_sidebar_widget("free_amazon_store_widget", __('Amazon Niche Store'), 'amazon_store_widget', array('description' => __('Display an Amazon niche store as a widget.')));
}
function amazon_store_widget_control() {
$options = $newoptions = get_option('amazon_store_widget');
if ( $_POST["amazon_store_widget_submit"] ) {
$newoptions['title'] = $_POST["amazon_store_widget_title"];
$newoptions['trackingid'] = $_POST["amazon_store_widget_trackingid"];
$newoptions['keywords'] = $_POST["amazon_store_widget_keywords"];
$newoptions['itemcount'] = $_POST["amazon_store_widget_itemcount"];
$newoptions['css'] = str_replace("\"", "'", str_replace("\\", "", $_POST["amazon_store_widget_css"]));
}
if ( empty($options['keywords']) && empty($options['trackingid']) ) {
$title = "Buy on Amazon";
$keywords = "";
$itemcount = 3;
$css = ".amazon-store-sidebar, .amazon-store-sidebar table {
font-size: small;
font-family: verdana,arial,helvetica,sans-serif;
width: 100%;
min-width: 100%;
}
.amazon-store-sidebar a {
text-decoration: none;
}
.amazon-store-sidebar td {
vertical-align: top;
font-size: small;
}
.amazon-store-sidebar-title {
text-decoration: underline;
font-weight: bold;
font-size: 110%;
}
.amazon-store-sidebar-manufacturer {
color: #000000;
}
.amazon-store-sidebar-price {
color: #990000;
font-weight: bold;
}
.amazon-store-sidebar-price strike {
color: #000000;
font-weight: normal;
}
.amazon-store-details-arrow {
color: #E47911;
font-size: 120%;
font-weight: bold;
font-family: verdana,arial,helvetica,sans-serif;
}
.amazon-store-sidebar-view-details {
text-decoration: underline;
color: #004B91;
font-family: verdana,arial,helvetica,sans-serif;
}
.amazon-store-sidebar-footer {
line-height: 14px;
font-size: 10px;
font-style: italic;
margin-top: -10px;
font-family: verdana,arial,helvetica,sans-serif;
}
";
}
else {
$title = $newoptions['title'];
$trackingid = $newoptions['trackingid'];
$keywords = $newoptions['keywords'];
$itemcount = $newoptions['itemcount'];
$css = $newoptions['css'];
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('amazon_store_widget', $options);
}
?>
" . $options['css'] . ""; echo $before_title . $title . $after_title; echo str_replace("\\", "", $before); echo amazon_store_display($options); if ( '%BEG_OF_TITLE%' != $args['before_title'] ) wp_cache_add('amazon_store_widget', ob_get_flush(), 'widget'); } } add_action('admin_menu', 'amazon_store_add_admin'); function amazon_store_add_admin() { add_submenu_page('tools.php', 'Add Amazon Niche Store Pages', 'Amazon Store', 8, 'amazon_niche_store', 'amazon_store_add_pages'); } function amazon_store_add_pages() { if ($_POST['action']) { if ($_POST['tracking_id']) { update_option('amazon_store_options', array( "tracking_id" => $_POST['tracking_id'], "customcss" => $_POST['customcss'], "post_status" => $_POST['post_status'], "rows" => $_POST['rows'], "columns" => $_POST['columns'], "pagination" => $_POST['pagination'], "logo" => $_POST['logo'] )); $post = 0; $addcount = 0; $options = get_option('amazon_store_options'); $tracking_id = $options['tracking_id']; $rows = $options['rows']; $columns = $options['columns']; if ($options['pagination'] == "yes") $pagination = " pagination=\"yes\""; else $pagination = ""; if ($options['customcss'] != "") $customcss = " customcss=\"" . $options['customcss'] . "\""; else $customcss = ""; $logo = $options['logo']; while ($_POST['title_' . $post]) { if ($_POST['title_' . $post] && $_POST['keywords_' . $post]) { $keywords = $_POST['keywords_' . $post]; $shortcode = str_replace(" ", " ", trim("[amazon trackingid=\"$tracking_id\" keywords=\"$keywords\" rows=\"$rows\" columns=\"$columns\" logo=\"$logo\" $pagination $customcss")) . "]"; $new_post = array(); $new_post['post_title'] = $_POST['title_' . $post]; $new_post['post_content'] = $shortcode; $new_post['post_status'] = $options['post_status']; $new_post['post_author'] = 1; $new_post['post_type'] = 'page'; $new_post['post_parent'] = $_POST['post_parent_' . $post]; $post_id = wp_insert_post($new_post); $addcount++; } $post++; } if ($addcount > 0) { echo "
Added $addcount page"; if ($addcount > 1) echo "s"; echo "
Updated your store page preferences. Note: This will not change existing store pages. You will have to edit existing pages manually.