cat_name;
$thecatname=str_replace("&","&",$thecatname);
$amazonstoreforwordpresscatdlist[$catforlist->cat_ID] = $thecatname;
}
$amazonstoreforwordpresscategories_tmp = array_unshift($amazonstoreforwordpresscatdlist, "Select a category:");
$defamazonstorepluginforwordpressoptions = array (
array("name" => "Amazon Plugin for WordPress Settings",
"type" => "heading"),
array("name" => "Change Text Editorial Review",
"id" => $amazonstorepluginforwordpressoptionsprefix."_replaceeditorialreview",
"std" => "Editorial Review",
"type" => "text"),
array("name" => "Change Text Your Shopping Cart Contents",
"id" => $amazonstorepluginforwordpressoptionsprefix."_viewcartheader",
"std" => "Your shopping cart contents",
"type" => "text"),
array("name" => "Your Currency Symbol",
"id" => $amazonstorepluginforwordpressoptionsprefix."_currencysymbol",
"std" => "",
"type" => "select",
"amazonstorepluginforwordpressoptions" => $currencysymbols),
array("name" => "Store Category ID",
"id" => $amazonstorepluginforwordpressoptionsprefix."_amazonstorecatname",
"std" => "",
"type" => "select",
"amazonstorepluginforwordpressoptions" => $amazonstoreforwordpresscatdlist),
array("name" => "Your Amazon Web Services Access Key ID",
"id" => $amazonstorepluginforwordpressoptionsprefix."_amazonkeyid",
"std" => "",
"type" => "text"),
array("name" => "Your Amazon Associates Tracking ID",
"id" => $amazonstorepluginforwordpressoptionsprefix."_amazonassoicatetag",
"std" => "",
"type" => "text"),
array("name" => "Setup which Amazon locale you wish to import from",
"id" => $amazonstorepluginforwordpressoptionsprefix."_amazonlocale",
"std" => "",
"type" => "select",
"amazonstorepluginforwordpressoptions" => $amazonlocales),
array("name" => "When you use the delete all posts option what status do you want to do with the deleted posts?",
"id" => $amazonstorepluginforwordpressoptionsprefix."_amazonstoredeletedpoststatus",
"std" => "",
"type" => "select",
"amazonstorepluginforwordpressoptions" => $amazondeletedpoststatus),
array("name" => "Credit plugin author?",
"id" => $amazonstorepluginforwordpressoptionsprefix."_creditplulginauthor",
"std" => "",
"type" => "select",
"amazonstorepluginforwordpressoptions" => array("yes","no")),
array("name" => "Disable Session Start?",
"id" => $amazonstorepluginforwordpressoptionsprefix."_disablesessionstart",
"std" => "",
"type" => "select",
"amazonstorepluginforwordpressoptions" => array("no","yes")),
);
function aspfwp_display_store()
{
global $aspfwp_pageid,$permalinkstructure;
$aspfwp_permalink=get_permalink($aspfwp_pageid);
if(!isset($permalinkstructure) || empty($permalinkstructure)){ $querysymbol="&";} else { $querysymbol="?";}
if(!isset($_REQUEST['action']) || empty($_REQUEST['action']))
{
aspfwp_the_store_list();
}
else
{
if(isset($_REQUEST['action']) && ($_REQUEST['action'] == 'addtocart'))
{
$itemtoaddtocart=$_REQUEST['itemid'];
$returntopageid=$_REQUEST['returnto'];
$itemquantity=$_REQUEST['quantity'];
if(isset($_SESSION['addtocartitemval']) && !empty($_SESSION['addtocartitemval']))
{
$addtocartitemval=( $_SESSION['addtocartitemval'] + 1 );
unset($_SESSION['addtocartitemval']);
$_SESSION['addtocartitemval']=$addtocartitemval;
}
else
{
$addtocartitemval=1;
$_SESSION['addtocartitemval']=$addtocartitemval;
}
if(isset($_SESSION['cartitems']) && !empty($_SESSION['cartitems']))
{
$currentitemsincart=$_SESSION['cartitems'];
if(alreadyincart($itemtoaddtocart))
{
// Do nothing
}
else
{
$currentitemsincart.=",$addtocartitemval-$returntopageid-$itemtoaddtocart-$itemquantity";
unset($_SESSION['cartitems']);
$_SESSION['cartitems']=$currentitemsincart;
}
aspfwp_view_cart();
}
else
{
$_SESSION['cartitems']="$addtocartitemval-$returntopageid-$itemtoaddtocart-$itemquantity";
aspfwp_view_cart();
}
//aspfwp_view_cart();
}
elseif(isset($_REQUEST['action']) && ($_REQUEST['action'] == 'updatequantity'))
{
$itemidtoupdate=$_REQUEST['itemid'];
$itemupdatequantity=$_REQUEST['itemquantity'];
if($itemupdatequantity == 0)
{
removeitemfromcart($itemidtoupdate);
}
else
{
if(isset($_SESSION['cartitems']) && !empty($_SESSION['cartitems']))
{
$sessioncartitems_upda=$_SESSION['cartitems'];
$updacartitems=array();
$thecartitems_upda=explode(",",$sessioncartitems_upda);
for ($i=0;isset($thecartitems_upda[$i]);++$i)
{
$updacartitems[]=$thecartitems_upda[$i];
}
foreach($updacartitems as $updacartitem)
{
list($itemnumval_upda,$itempostid_upda,$itemasin_upda,$numberof_upda) = split('[-]', $updacartitem);
if($itemasin_upda == $itemidtoupdate)
{
$olditemval=$itemnumval_upda.'-'.$itempostid_upda.'-'.$itemasin_upda.'-'.$numberof_upda;
$updateditemvals=$itemnumval_upda.'-'.$itempostid_upda.'-'.$itemasin_upda.'-'.$itemupdatequantity;
}
}
$sessioncartitems_upda=str_replace($olditemval,$updateditemvals,$sessioncartitems_upda);
unset($_SESSION['cartitems']);
$_SESSION['cartitems']=$sessioncartitems_upda;
}
}
aspfwp_view_cart();
}
elseif(isset($_REQUEST['action']) && ($_REQUEST['action'] == 'viewcart'))
{
aspfwp_view_cart();
}
elseif(isset($_REQUEST['action']) && ($_REQUEST['action'] == 'emptycart'))
{
if(isset($_SESSION['cartitems']) && !empty($_SESSION['cartitems']))
{
unset($_SESSION['cartitems']);
}
if(isset($_SESSION['addtocartitemval']) && !empty($_SESSION['addtocartitemval']))
{
unset($_SESSION['addtocartitemval']);
}
aspfwp_view_cart();
}
elseif(!isset($_REQUEST['action']) || empty($_REQUEST['action']))
{
aspfwp_the_store_list();
}
}
}
function amazonstorepluginforwordpress_addcss()
{
global $amazonstorepluginforwordpress_plugin_url;
$amazonstorepluginforwordpressstylesheet="amastyle.css";
echo "\n".'';
global $amazonstorepluginforwordpress_plugin_url;
$amazonstorepluginforwordpressstylesheet="amastyle.css";
if(file_exists(TEMPLATEPATH . '/'. $amazonstorepluginforwordpressstylesheet))
{
echo "\n".'';
}elseif(file_exists(STYLESHEETPATH . '/'. $amazonstorepluginforwordpressstylesheet)){
echo "\n".'';
}else {
echo "\n".'';
}
}
function amazonstorepluginforwordpressjs() {
global $amazonstorepluginforwordpress_plugin_url;
wp_enqueue_script('jquery');
wp_enqueue_script('instacookie', $amazonstorepluginforwordpress_plugin_url.'js/instacookie.js', array('jquery'));
}
function amazonstorepluginforwordpress_install()
{
global $wpdb,$amazonstorepluginforwordpress_version;
add_option("amazonstorepluginforwordpress_version", $amazonstorepluginforwordpress_version);
}
// Configure the management menu
function amazonstorepluginforwordpress_adminmenu()
{ global $myasfwpname;
add_menu_page($myasfwpname, 'Amazon Shop', 'activate_plugins', 'amazonstorepluginforwordpress.php', 'amazonstorepluginforwordpress_display_admin_menu', '');
add_submenu_page('amazonstorepluginforwordpress.php', 'Import Products', 'Import', 'activate_plugins', 'aspfwpimport', 'amazonstorepluginforwordpress_makepostform');
//add_submenu_page('amazonstorepluginforwordpress.php', 'Delete All Products', 'Delete All', 'activate_plugins','aspfwpdelete', 'aspfwpdeleteall');
//add_submenu_page('amazonstorepluginforwordpress.php', 'Setup Options', 'Settings', 'activate_plugins', 'aspfwpsettings','amazonstorepluginforwordpress_admin');
add_submenu_page('amazonstorepluginforwordpress.php', 'Uninstall', 'Uninstall', 'activate_plugins', 'aspfwpuninstall', 'amazonstorepluginforwordpress_uninstall');
}
//Display the top level menu
function amazonstorepluginforwordpress_display_admin_menu()
{
global $wpdb,$table_prefix,$amazonstorepluginforwordpressoptionsprefix;
global $aspfwpops;
$amazonstorepluginforwordpress_amazonkeyid='';
$amazonstorepluginforwordpress_amazonassoicatetag='';
if(isset($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonkeyid']) && !empty($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonkeyid'])){
$amazonstorepluginforwordpress_amazonkeyid=$aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonkeyid'];
}
if(isset($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonassoicatetag']) && !empty($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonassoicatetag'])){
$amazonstorepluginforwordpress_amazonassoicatetag=$aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonassoicatetag'];
}
echo "
".AMAPGFWPNAME." ";
if(!isset($amazonstorepluginforwordpress_amazonkeyid) || !isset($amazonstorepluginforwordpress_amazonassoicatetag) )
{
_e("You have not setup the necessary Amazon associate and web services information. These need to be set for the plugin to work", "aspfwp");
}
else
{
_e("Use the Import link under the Amazon Shop menu tab to import products from Amazon. The Delete All link will delete all your imported products. You need an amazon web services account to use this plugin.
If you do not have an Amazon Web Services Access Key ID you may obtain one by visiting http://aws.amazon.com/ .");
echo "
";
}
$amazonstorepluginforwordpressaction='';
if( isset($_REQUEST['amazonstorepluginforwordpressaction']) && !empty($_REQUEST['amazonstorepluginforwordpressaction']) )
{
$amazonstorepluginforwordpressaction = $_REQUEST['amazonstorepluginforwordpressaction'];
}
if($amazonstorepluginforwordpressaction == 'aspfwpimportposts')
{
amazonstorepluginforwordpress_makepostform();
}
elseif($amazonstorepluginforwordpressaction == 'aspfwpuninstall')
{
$message="
If you are certain you wish to uninstall this plugin please click the link below to start the procedure
Start Uninstalling Plugin
";
echo "$message";
}
elseif($amazonstorepluginforwordpressaction == 'aspfwpuninstalldo')
{
$message=amazonstorepluginforwordpress_uninstall();
echo "$message";
}
elseif($amazonstorepluginforwordpressaction == 'aspfwpdeleteall')
{
$message="
Clicking the link below will delete all your imported product posts. That means everything you have imported regardless of the category.
Yes, Delete All Posts
";
echo "$message";
}
elseif($amazonstorepluginforwordpressaction == 'aspfwpdeletealldo')
{
$message=amazonstorepluginforwordpress_deleteall();
echo "$message";
}
else
{
$aspfwpkeyset=aspfwp_check_settings();
if(!($aspfwpkeyset)){aspfwp_redirect_to_settings();}
else
{
amazonstorepluginforwordpress_admin();
}
}
}
function aspfwp_check_settings()
{
global $amazonstorepluginforwordpressoptionsprefix;
global $aspfwpops;
$amazonstorepluginforwordpress_amazonkeyid='';
$amazonstorepluginforwordpress_amazonassoicatetag='';
if(isset($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonkeyid']) && !empty($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonkeyid'])){
$amazonstorepluginforwordpress_amazonkeyid=$aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonkeyid'];
}
if(isset($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonassoicatetag']) && !empty($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonassoicatetag'])){
$amazonstorepluginforwordpress_amazonassoicatetag=$aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonassoicatetag'];
}
if( ($amazonstorepluginforwordpress_amazonkeyid == '') || ($amazonstorepluginforwordpress_amazonkeyid == ''))
{
return 0;
}
else
{
return 1;
}
}
function aspfwp_redirect_to_settings()
{
echo "
";
_e("You have not setup the necessary Amazon associate and web services information. These need to be set for the plugin to work.", "aspfwp");
echo "
";
amazonstorepluginforwordpress_admin();
}
function amazonstorepluginforwordpress_makepostform()
{
$aspfwpkeyset=aspfwp_check_settings();
if(!($aspfwpkeyset)){aspfwp_redirect_to_settings();}
else
{
$amazonstorepluginforwordpressaction='';
$amazonstorepluginforwordpress_category='';
$amazonstorepluginforwordpress_search_keywords='';
if( isset($_REQUEST['amazonstorepluginforwordpressaction']) && !empty($_REQUEST['amazonstorepluginforwordpressaction']) )
{
$amazonstorepluginforwordpressaction = $_REQUEST['amazonstorepluginforwordpressaction'];
}
if( isset($_REQUEST['amazonstorepluginforwordpress_category']) && !empty($_REQUEST['amazonstorepluginforwordpress_category']) )
{
$amazonstorepluginforwordpress_category=$_REQUEST['amazonstorepluginforwordpress_category'];
}
if( isset($_REQUEST['amazonstorepluginforwordpress_search_keyword']) && !empty($_REQUEST['amazonstorepluginforwordpress_search_keyword']) )
{
$amazonstorepluginforwordpress_search_keywords=$_REQUEST['amazonstorepluginforwordpress_search_keyword'];
}
$amazonstorepluginforwordpress_search_keyword=explode(",",$amazonstorepluginforwordpress_search_keywords);
$amazonstorepluginforwordpress_keywords=array();
for ($i=0;isset($amazonstorepluginforwordpress_search_keyword[$i]);++$i)
{
$amazonstorepluginforwordpress_keywords[]=$amazonstorepluginforwordpress_search_keyword[$i];
}
if( isset($_REQUEST['amazonstorepluginforwordpress_amazon_searchindex']) && !empty($_REQUEST['amazonstorepluginforwordpress_amazon_searchindex']) )
{
$the_amazonstorepluginforwordpress_searchindex=$_REQUEST['amazonstorepluginforwordpress_amazon_searchindex'];
}
if( isset($_REQUEST['amazonstorepluginforwordpress_awssecaccesskey']) && !empty($_REQUEST['amazonstorepluginforwordpress_awssecaccesskey']) )
{
$the_amazonstorepluginforwordpress_secretkey=trim($_REQUEST['amazonstorepluginforwordpress_awssecaccesskey']);
}
if($amazonstorepluginforwordpressaction == 'wpamaexecuteimport')
{
amazonstorepluginforwordpress_makepost($amazonstorepluginforwordpress_category,$amazonstorepluginforwordpress_keywords,$the_amazonstorepluginforwordpress_searchindex,$the_amazonstorepluginforwordpress_secretkey);
$message="
Task Completed
";
echo "$message";
}
else
{
echo "
";
echo "
";
echo AMAPGFWPNAME;
echo " ";
echo "
";
_e("Import Products","aspfwp");
echo " ";
echo "
";
_e("Select the category to populate, enter the keywords to look for items and set the Amazon Search Index");
echo "
";
echo "
";
echo "
";
}
}
}
function amazonstorepluginforwordpress_makepost($amazonstorepluginforwordpress_category,$amazonstorepluginforwordpress_keywords,$the_amazonstorepluginforwordpress_searchindex,$the_amazonstorepluginforwordpress_secretkey)
{
global $wpdb,$amazonstorepluginforwordpressoptionsprefix;
global $aspfwpops;
$AWS_ACCESS_KEY_ID=$aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonkeyid'];
$Amazon_Associate_Tag=$aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonassoicatetag'];
$ItemPage='';
$AWS_SECRET_ACCESS_KEY = $the_amazonstorepluginforwordpress_secretkey;
$amazonstorepluginforwordpress_keywords=str_replace(" ","%20",$amazonstorepluginforwordpress_keywords);
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'US')
{
$amazonstorepluginforwordpress_base_url = "http://ecs.amazonaws.com";
$amazonstorepluginforwordpress_localender="com";
}
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'UK')
{
$amazonstorepluginforwordpress_base_url = "http://ecs.amazonaws.co.uk";
$amazonstorepluginforwordpress_localender="co.uk";
}
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'FR')
{
$amazonstorepluginforwordpress_base_url = "http://ecs.amazonaws.fr";
$amazonstorepluginforwordpress_localender="fr";
}
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'JP')
{
$amazonstorepluginforwordpress_base_url = "http://ecs.amazonaws.jp";
$amazonstorepluginforwordpress_localender="jp";
}
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'CA')
{
$amazonstorepluginforwordpress_base_url = "http://ecs.amazonaws.ca";
$amazonstorepluginforwordpress_localender="ca";
}
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'DE')
{
$amazonstorepluginforwordpress_base_url = "http://ecs.amazonaws.de";
$amazonstorepluginforwordpress_localender="de";
}
foreach ($amazonstorepluginforwordpress_keywords as $amazonstorepluginforwordpress_keyword)
{
// Begin handling the signed key stuff
// End handling the signed key stuff
//ResponseGroup=Large,Reviews,EditorialReview
$amazonstorepluginforwordpress_request_url = 'Operation=ItemSearch&ResponseGroup=Large&ItemPage=1&Version=2009-03-31&SearchIndex='.$the_amazonstorepluginforwordpress_searchindex.'&Keywords='.$amazonstorepluginforwordpress_keyword.'&Condition=All&Availability=Available';
$amazonstorepluginforwordpress_request_url = 'Service=AWSECommerceService&'.
'AWSAccessKeyId='.$AWS_ACCESS_KEY_ID.'&'.
'AssociateTag='.$Amazon_Associate_Tag.'&'.
'Timestamp='.gmdate("Y-m-d\TH:i:s\Z").'&'.
$amazonstorepluginforwordpress_request_url;
$amazonstorepluginforwordpress_request_url = str_replace(',','%2C', $amazonstorepluginforwordpress_request_url);
$amazonstorepluginforwordpress_request_url = str_replace(':','%3A', $amazonstorepluginforwordpress_request_url);
$reqarr = explode('&',$amazonstorepluginforwordpress_request_url);
sort($reqarr);
$string_to_sign = implode("&", $reqarr);
$string_to_sign = "GET\necs.amazonaws.".$amazonstorepluginforwordpress_localender."\n/onca/xml\n".$string_to_sign;
$signature = urlencode(base64_encode(hash_hmac("sha256", $string_to_sign, $the_amazonstorepluginforwordpress_secretkey, True)));
$amazonstorepluginforwordpress_request_url .= '&Signature='.$signature;
$amazonstorepluginforwordpress_request_url = $amazonstorepluginforwordpress_base_url.'/onca/xml?'.$amazonstorepluginforwordpress_request_url;
//Get the data from amazon
$amazonstorepluginforwordpress_request="$amazonstorepluginforwordpress_request_url";
//The use of `file_get_contents` may not work on all servers because it relies on the ability to open remote URLs using the file manipulation functions.
//PHP gives you the ability to disable this functionality in your php.ini file and many administrators do so for security reasons.
//If your administrator has not done so, you can comment out the following 5 lines of code and uncomment the 6th.
$session = curl_init($amazonstorepluginforwordpress_request);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$amazonstorepluginforwordpress_response = curl_exec($session);
curl_close($session);
$amazonstorepluginforwordpress_response = file_get_contents($amazonstorepluginforwordpress_request);
//print_r($amazonstorepluginforwordpress_response);
//die;
$amazonstorepluginforwordpress_parsed_xml = simplexml_load_string($amazonstorepluginforwordpress_response);
$amazonstorepluginforwordpress_numOfItems = $amazonstorepluginforwordpress_parsed_xml->Items->TotalResults;
$amazonstorepluginforwordpress_totalPages = $amazonstorepluginforwordpress_parsed_xml->Items->TotalPages;
if($amazonstorepluginforwordpress_numOfItems > 0)
{
foreach($amazonstorepluginforwordpress_parsed_xml->Items->Item as $current)
{
$amazonstorepluginforwordpress_itemtitle=$current->ItemAttributes->Title;
$sanitizeditemtitle=sanitize_title($amazonstorepluginforwordpress_itemtitle);
if( !(amazonstorepluginforwordpress_entry_exists($sanitizeditemtitle)) )
{
$amazonstorepluginforwordpress_itembuylink=$current->DetailPageURL;
$amazonstorepluginforwordpress_itemeditorialreview=$current->EditorialReviews->EditorialReview->Content;
$amazonstorepluginforwordpress_itemcustomerreview=$current->CustomerReviews->Review->Summary;
$amazonstorepluginforwordpress_itemlistprice=$current->ItemAttributes->ListPrice->FormattedPrice;
$amazonstorepluginforwordpress_itemnewprice=$current->OfferSummary->LowestNewPrice->FormattedPrice;
$amazonstorepluginforwordpress_itemimage=$current->LargeImage->URL;
$amazonstorepluginforwordpress_itembrand=$current->ItemAttributes->Brand;
$amazonstorepluginforwordpress_itemauthor=$current->ItemAttributes->Author;
$amazonstorepluginforwordpress_itempublisher=$current->ItemAttributes->Publisher;
$amazonstorepluginforwordpress_itemasin=$current->ASIN;
$amazonstorepluginforwordpress_itemisbn=$current->ItemAttributes->ISBN;
//$amazonstorepluginforwordpress_itemfeatureitem=$current->ItemAttributes->Feature;
$amazonstorepluginforwordpress_itemthumb=$current->MediumImage->URL;
if( isset($amazonstorepluginforwordpress_itemeditorialreview) && !empty($amazonstorepluginforwordpress_itemeditorialreview) )
{
//if(strlen($amazonstorepluginforwordpress_itemeditorialreview) > 500){
//$amazonstorepluginforwordpress_itemeditorialreview=LimitText($amazonstorepluginforwordpress_itemeditorialreview,10,500,"");
//$amazonstorepluginforwordpress_itemeditorialreview.="...";
//}
$amazonstorepluginforwordpress_itemeditorialreview = str_replace("
","",$amazonstorepluginforwordpress_itemeditorialreview);
$amazonstorepluginforwordpress_itemeditorialreview = str_replace("
","",$amazonstorepluginforwordpress_itemeditorialreview);
$amazonstorepluginforwordpress_itemdescription="
$amazonstorepluginforwordpress_itemeditorialreview
";
}
// Add the post to the wordpress database
$amazonstorepluginforwordpress_category_forwp=array("$amazonstorepluginforwordpress_category");
$amazonstorepluginforwordpress_post_category = $amazonstorepluginforwordpress_category_forwp;
$amazonstorepluginforwordpress_postdate_year=date('Y');
$amazonstorepluginforwordpress_postdatemonth=date('m');
$amazonstorepluginforwordpress_postdate_month=rand($amazonstorepluginforwordpress_postdatemonth,12);
if($amazonstorepluginforwordpress_postdate_month == 1)
{
$maxdays=31;
}
if($amazonstorepluginforwordpress_postdate_month == 2)
{
if ($amazonstorepluginforwordpress_postdate_year % 4 != 0)
{
$maxdays=28;
}
else
{
if ($amazonstorepluginforwordpress_postdate_year % 100 != 0)
{
$maxdays=29;
}
else
{
if ($amazonstorepluginforwordpress_postdate_year % 400 != 0)
{
$maxdays=28;
}
else
{
$maxdays=29;
}
}
}
}
if($amazonstorepluginforwordpress_postdate_month == 3)
{
$maxdays=31;
}
if($amazonstorepluginforwordpress_postdate_month == 4)
{
$maxdays=30;
}
if($amazonstorepluginforwordpress_postdate_month == 5)
{
$maxdays=31;
}
if($amazonstorepluginforwordpress_postdate_month == 6)
{
$maxdays=30;
}
if($amazonstorepluginforwordpress_postdate_month == 7)
{
$maxdays=31;
}
if($amazonstorepluginforwordpress_postdate_month == 8)
{
$maxdays=31;
}
if($amazonstorepluginforwordpress_postdate_month == 9)
{
$maxdays=30;
}
if($amazonstorepluginforwordpress_postdate_month == 10)
{
$maxdays=31;
}
if($amazonstorepluginforwordpress_postdate_month == 11)
{
$maxdays=30;
}
if($amazonstorepluginforwordpress_postdate_month == 12)
{
$maxdays=31;
}
$amazonstorepluginforwordpress_postdate_day=rand(1,$maxdays);
$amazonstorepluginforwordpress_posttime_hour=rand(1,24);
$amazonstorepluginforwordpress_posttime_minute=rand(1,59);
$amazonstorepluginforwordpress_posttime_second=rand(1,59);
$amazonstorepluginforwordpress_postdate_time="$amazonstorepluginforwordpress_posttime_hour:$amazonstorepluginforwordpress_posttime_minute:$amazonstorepluginforwordpress_posttime_second";
$amazonstorepluginforwordpress_postdate="$amazonstorepluginforwordpress_postdate_year-$amazonstorepluginforwordpress_postdate_month-$amazonstorepluginforwordpress_postdate_day $amazonstorepluginforwordpress_postdate_time";
$amazonstorepluginforwordpress_post_content="$amazonstorepluginforwordpress_itemdescription";
$amazonstorepluginforwordpress_post_title="$amazonstorepluginforwordpress_itemtitle";
if(is_user_logged_in())
{
global $current_user;
get_currentuserinfo();
$amazonstorepluginforwordpress_user_id=$current_user->ID;
}
else
{
$amazonstorepluginforwordpress_user_id=1;
}
$aspfwp_post_id = wp_insert_post( array(
'post_author' => $amazonstorepluginforwordpress_user_id,
'post_title' => $amazonstorepluginforwordpress_post_title,
'post_content' => $amazonstorepluginforwordpress_post_content,
'post_category' => $amazonstorepluginforwordpress_post_category,
'post_type' => 'post',
'post_status' => 'publish',
'post_date' => $amazonstorepluginforwordpress_postdate,
'post_date_gmt' => $amazonstorepluginforwordpress_postdate
));
if(isset($amazonstorepluginforwordpress_itemimage) && !empty($amazonstorepluginforwordpress_itemimage))
{
add_post_meta($aspfwp_post_id, 'aspfwpimage', "$amazonstorepluginforwordpress_itemimage", true) or update_post_meta($aspfwp_post_id, 'aspfwpimage', $amazonstorepluginforwordpress_itemimage);
}
if(isset($amazonstorepluginforwordpress_itemthumb) && !empty($amazonstorepluginforwordpress_itemthumb))
{
add_post_meta($aspfwp_post_id, 'aspfwpthumb', "$amazonstorepluginforwordpress_itemthumb", true) or update_post_meta($aspfwp_post_id, 'aspfwpthumb', $amazonstorepluginforwordpress_itemthumb);
}
if(isset($amazonstorepluginforwordpress_itembuylink) && !empty($amazonstorepluginforwordpress_itembuylink))
{
add_post_meta($aspfwp_post_id, 'aspfwpbuylink', "$amazonstorepluginforwordpress_itembuylink", true) or update_post_meta($aspfwp_post_id, 'aspfwpbuylink', $amazonstorepluginforwordpress_itembuylink);
}
if(isset($amazonstorepluginforwordpress_itemlistprice) && !empty($amazonstorepluginforwordpress_itemlistprice))
{
add_post_meta($aspfwp_post_id, 'aspfwplistprice', "$amazonstorepluginforwordpress_itemlistprice", true) or update_post_meta($aspfwp_post_id, 'aspfwplistprice', $amazonstorepluginforwordpress_itemlistprice);
}
if(isset($amazonstorepluginforwordpress_itemnewprice) && !empty($amazonstorepluginforwordpress_itemnewprice))
{
add_post_meta($aspfwp_post_id, 'aspfwpnewprice', "$amazonstorepluginforwordpress_itemnewprice", true) or update_post_meta($aspfwp_post_id, 'aspfwpnewprice', $amazonstorepluginforwordpress_itemnewprice);
}
//$itemfeatures=array();
//foreach($current->ItemAttributes->Feature as $amazonstorepluginforwordpress_itemfeature)
//{
// $itemfeatures[]="
$amazonstorepluginforwordpress_itemfeature ";
//}
//if(isset($itemfeatures) && !empty($itemfeatures))
//{
// add_post_meta($aspfwp_post_id, 'features', $itemfeatures, true) or update_post_meta($aspfwp_post_id, features, $itemfeatures);
//}
if(isset($amazonstorepluginforwordpress_itembrand) && !empty($amazonstorepluginforwordpress_itembrand))
{
add_post_meta($aspfwp_post_id, 'aspfwpbrand', "$amazonstorepluginforwordpress_itembrand", true) or update_post_meta($aspfwp_post_id, 'aspfwpbrand', $amazonstorepluginforwordpress_itembrand);
}
if(isset($amazonstorepluginforwordpress_itemauthor) && !empty($amazonstorepluginforwordpress_itemauthor))
{
add_post_meta($aspfwp_post_id, 'aspfwpauthor', "$amazonstorepluginforwordpress_itemauthor", true) or update_post_meta($aspfwp_post_id, 'aspfwpauthor', $amazonstorepluginforwordpress_itemauthor);
}
if(isset($amazonstorepluginforwordpress_itempublisher) && !empty($amazonstorepluginforwordpress_itempublisher))
{
add_post_meta($aspfwp_post_id, 'aspfwppublisher', "$amazonstorepluginforwordpress_itempublisher", true) or update_post_meta($aspfwp_post_id, 'aspfwppublisher', $amazonstorepluginforwordpress_itempublisher);
}
if(isset($amazonstorepluginforwordpress_manufacturer) && !empty($amazonstorepluginforwordpress_manufacturer))
{
add_post_meta($aspfwp_post_id, 'aspfwpmanufacturer', "$amazonstorepluginforwordpress_manufacturer", true) or update_post_meta($aspfwp_post_id, 'aspfwpmanufacturer', $amazonstorepluginforwordpress_manufacturer);
}
if(isset($amazonstorepluginforwordpress_itemasin) && !empty($amazonstorepluginforwordpress_itemasin))
{
add_post_meta($aspfwp_post_id, 'aspfwpasin', "$amazonstorepluginforwordpress_itemasin", true) or update_post_meta($aspfwp_post_id, 'aspfwpasin', $amazonstorepluginforwordpress_itemasin);
}
if(isset($amazonstorepluginforwordpress_itemisbn) && !empty($amazonstorepluginforwordpress_itemisbn))
{
add_post_meta($aspfwp_post_id, 'aspfwpisbn', "$amazonstorepluginforwordpress_itemisbn", true) or update_post_meta($aspfwp_post_id, 'aspfwpisbn', $amazonstorepluginforwordpress_itemisbn);
}
if( isset($amazonstorepluginforwordpress_itemcustomerreview) && !empty($amazonstorepluginforwordpress_itemcustomerreview) )
{
foreach($current->CustomerReviews->Review->Summary as $amazonstorepluginforwordpress_whatcustomersaresaying)
{
$reviewername=$current->CustomerReviews->Review->Reviewer->Name;
$data = array(
'comment_post_ID' => $aspfwp_post_id,
'comment_author' => $reviewername,
'comment_author_email' => '',
'comment_author_url' => 'http://',
'comment_content' => $amazonstorepluginforwordpress_whatcustomersaresaying,
'comment_type' => '',
'comment_parent' => 0,
'user_ID' => '',
'comment_author_IP' => '',
'comment_agent' => '',
'comment_date' => $time,
'comment_date_gmt' => $time,
'comment_approved' => 1,
);
wp_insert_comment($data);
} // Close foreach $current->CustomerReviews
} // Close if isset $amazonstorepluginforwordpress_itemcustomerreview
} // Close if the item title already exists do not add it
} // Close for each $amazonstorepluginforwordpress_parsed_xml->Items->Item as $current
} // Close if $amazonstorepluginforwordpress_numOfItems greater 0
} // Close foreach $amazonstorepluginforwordpress_keywords
}
function amazonstorepluginforwordpress_uninstall()
{
global $wpdb,$amazonstorepluginforwordpress_version,$table_prefix,$amazonstorepluginforwordpressoptionsprefix;
// Remove the amazonstorepluginforwordpress options
$query="DELETE FROM {$table_prefix}options WHERE option_name LIKE '%$amazonstorepluginforwordpressoptionsprefix%'";
@mysql_query($query);
$amazonstorepluginforwordpress_thepluginfile="amazonstorepluginforwordpress/$amazonstorepluginforwordpress_version.php";
$amazonstorepluginforwordpress_current = get_settings('active_plugins');
array_splice($amazonstorepluginforwordpress_current, array_search( $amazonstorepluginforwordpress_thepluginfile, $amazonstorepluginforwordpress_current), 1 );
update_option('active_plugins', $amazonstorepluginforwordpress_current);
do_action('deactivate_' . $amazonstorepluginforwordpress_thepluginfile );
$message="
";
return $message;
}
function aspfwpdeleteall()
{
?>
".AMAPGFWPNAME." ";
$message="
Clicking the link below will delete all your imported product posts. That means everything you have imported regardless of the category.
Yes, Delete All Posts
";
echo "$message";
?>
$aspfwpcatid,'post_status' => array("publish","pending","draft","private","static","object","attachment","inherit","future"));
$myposts = get_posts($mpargs);
$aspfwp_trash_postarr = array();
foreach($myposts as $post) :
$aspfwp_trash_postarr['ID'] = $post->ID;
$aspfwp_trash_postarr['post_status'] = $aspfwpdeletedpoststatus;
wp_update_post( $aspfwp_trash_postarr );
endforeach;
// Update the post into the database
endif;
$message="
";
$message.=__("Job completed. Posts deleted.");
$mesage.="
";
return $message;
}
function amazonstorepluginforwordpress_entry_exists($amazonstorepluginforwordpress_post_title)
{
global $wpdb,$table_prefix;
$myreturn=false;
$query="SELECT post_name FROM {$table_prefix}posts WHERE post_name='".$amazonstorepluginforwordpress_post_title."'";
if (!($res=@mysql_query($query))) {die("
A fatal MySQL error occured .\n
Query: " . $query . "
\nError: (" . mysql_errno() . ") " . mysql_error()); }
if (mysql_num_rows($res) && mysql_result($res,0,0)) {
$myreturn=true;
}
return $myreturn;
}
// create checkout tiny url
function get_tiny_url($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
if(strstr($data, 'http://'))
{
return $data;
}
}
function instacart_is_empty()
{
$instacartisempty=true;
if(isset($_SESSION['cartitems']) && !empty($_SESSION['cartitems']))
{
$instacartisempty=false;
}
return $instacartisempty;
}
function get_item_quantity($postID)
{
$numberofitems='';
if(isset($_SESSION['cartitems']) && !empty($_SESSION['cartitems']))
{
$sessioncartitems3=$_SESSION['cartitems'];
$totalofitems3=array();
$numberofitemsincartcheck3=explode(",",$sessioncartitems3);
for ($i=0;isset($numberofitemsincartcheck3[$i]);++$i)
{
$totalofitems3[]=$numberofitemsincartcheck3[$i];
}
$itemarrayforsum3=array();
foreach($totalofitems3 as $itemitem3)
{
list($itemnumval3,$itempostid3,$itemasin3,$numberof3) = split('[-]', $itemitem3);
if($itempostid3 == $postID)
{
$numberofitems=$numberof3;
}
}
}
return $numberofitems;
}
function aspfwp_configure_checkout_link()
{
global $amazonstorepluginforwordpressoptionsprefix;
global $aspfwpops;
$listofitemsincart='';
$Amazon_Associate_Tag=$aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonassoicatetag'];
if(isset($_SESSION['cartitems']) && !empty($_SESSION['cartitems']))
{
$sessioncartitems=$_SESSION['cartitems'];
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'US')
{
$amazonstorepluginforwordpress_localender="com";
}
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'UK')
{
$amazonstorepluginforwordpress_localender="co.uk";
}
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'FR')
{
$amazonstorepluginforwordpress_localender="fr";
}
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'JP')
{
$amazonstorepluginforwordpress_localender="jp";
}
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'CA')
{
$amazonstorepluginforwordpress_localender="ca";
}
if($aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_amazonlocale'] == 'DE')
{
$amazonstorepluginforwordpress_localender="de";
}
$totalofitems=array();
$numberofitemsincartcheck=explode(",",$sessioncartitems);
for ($i=0;isset($numberofitemsincartcheck[$i]);++$i)
{
$totalofitems[]=$numberofitemsincartcheck[$i];
foreach($totalofitems as $itemitem)
{
list($itemnumval,$itempostid,$itemasin,$numberof) = explode('-', $itemitem);
}
$listofitemsincart.="ASIN.$itemnumval=$itemasin&Quantity.$itemnumval=$numberof&";
}
$instacheckouturl="http://www.amazon.";
$instacheckouturl.="$amazonstorepluginforwordpress_localender";
$instacheckouturl.="/gp/aws/cart/add.html";
$instacheckouturl.="?$listofitemsincart";
$instacheckouturl.="AssociateTag=$Amazon_Associate_Tag";
$tinyinstacheckouturl = get_tiny_url($instacheckouturl);
if(isset($tinyinstacheckouturl) && !empty($tinyinstacheckouturl))
{
$instacheckouturl=$tinyinstacheckouturl;
}
else
{
$instacheckouturl=$instacheckouturl;
}
echo "
";
_e("Checkout");
echo " ";
}
else
{
}
}
function aspfwp_total_items_in_cart()
{
$valtotalitemsincart='';
if(isset($_SESSION['cartitems']) && !empty($_SESSION['cartitems']))
{
$sessioncartitems=$_SESSION['cartitems'];
$totalofitems=array();
$numberofitemsincartcheck=explode(",",$sessioncartitems);
for ($i=0;isset($numberofitemsincartcheck[$i]);++$i)
{
$totalofitems[]=$numberofitemsincartcheck[$i];
$itemarrayforsum=array();
foreach($totalofitems as $itemitem)
{
list($itemnumval,$itempostid,$itemasin,$numberof) = split('[-]', $itemitem);
$itemarrayforsum[]=$numberof;
}
}
$totalitemsincart=array_sum($itemarrayforsum);
$valtotalitemsincart="
";
$valtotalitemsincart.=__("You have");
$valtotalitemsincart.=" [ $totalitemsincart ] ";
$valtotalitemsincart.=__("items in your shopping cart");
$valtotalitemsincart.=" ";
}
return $valtotalitemsincart;
}
function alreadyincart($thecartitemtocheckfor)
{
$itemalreadyincart=false;
if(isset($_SESSION['cartitems']) && !empty($_SESSION['cartitems']))
{
$sessioncartitems_ain=$_SESSION['cartitems'];
$aincartitems=array();
$thecartitems_ain=explode(",",$sessioncartitems_ain);
for ($i=0;isset($thecartitems_ain[$i]);++$i)
{
$aincartitems[]=$thecartitems_ain[$i];
}
foreach($aincartitems as $aincartitem)
{
list($itemnumval_ain,$itempostid_ain,$itemasin_ain,$numberof_ain) = split('[-]', $aincartitem);
if($itemasin_ain == $thecartitemtocheckfor)
{
$itemalreadyincart=true;
}
}
}
return $itemalreadyincart;
}
function removeitemfromcart($itemidtoremove)
{
if(isset($_SESSION['cartitems']) && !empty($_SESSION['cartitems']))
{
$sessioncartitems_remoitem=$_SESSION['cartitems'];
$remoitemcartitems=array();
$thecartitems_remoitem=explode(",",$sessioncartitems_remoitem);
for ($i=0;isset($thecartitems_remoitem[$i]);++$i)
{
$remoitemcartitems[]=$thecartitems_remoitem[$i];
}
foreach($remoitemcartitems as $remoitemcartitem)
{
list($itemnumval_remoitem,$itempostid_remoitem,$itemasin_remoitem,$numberof_remoitem) = split('[-]', $remoitemcartitem);
if($itemasin_remoitem == $itemidtoremove)
{
$remo_olditemval=$itemnumval_remoitem.'-'.$itempostid_remoitem.'-'.$itemasin_remoitem.'-'.$numberof_remoitem;
}
}
$sessioncartitems_remoitem=str_replace($remo_olditemval,"",$sessioncartitems_remoitem);
$sessioncartitems_remoitem=str_replace(",,",",",$sessioncartitems_remoitem);
unset($_SESSION['cartitems']);
$_SESSION['cartitems']=$sessioncartitems_remoitem;
}
}
function amazonstorepluginforwordpress_add_admin() {
//replace submenu page
}
function get_amazonstorepluginforwordpressoptions()
{
$mypsamazonstorepluginforwordpressoptions=array();
global $amazonstorepluginforwordpressoptionsprefix;
$pstandamazonstorepluginforwordpressoptions=get_option($amazonstorepluginforwordpressoptionsprefix.'_options');
if(isset($pstandamazonstorepluginforwordpressoptions) && !empty($pstandamazonstorepluginforwordpressoptions))
{
foreach ($pstandamazonstorepluginforwordpressoptions as $pstandoption)
{
if(isset($pstandoption['id']) && !empty($pstandoption['id']))
{
$mypsamazonstorepluginforwordpressoptions[$pstandoption['id']]=$pstandoption['std'];
}
}
}
return $mypsamazonstorepluginforwordpressoptions;
}
function amazonstorepluginforwordpress_check_for_amazonstorepluginforwordpressoptions()
{
global $amazonstorepluginforwordpressoptionsprefix,$defamazonstorepluginforwordpressoptions;
$mythemeamazonstorepluginforwordpressoptions=$amazonstorepluginforwordpressoptionsprefix.'_options';
$mysavedthemeamazonstorepluginforwordpressoptions=get_option($mythemeamazonstorepluginforwordpressoptions);
$amazonstorepluginforwordpressoptions = $mysavedthemeamazonstorepluginforwordpressoptions;
if (!isset($amazonstorepluginforwordpressoptions) || empty($amazonstorepluginforwordpressoptions) || !is_array($amazonstorepluginforwordpressoptions))
{
$amazonstorepluginforwordpressoptions = $defamazonstorepluginforwordpressoptions;
foreach ($amazonstorepluginforwordpressoptions as $optionvalue)
{
if(!isset($optionvalue['id']) || empty($optionvalue['id']))
{
$optionvalue['id']='';
}
if(!isset($optionvalue['amazonstorepluginforwordpressoptions']) || empty($optionvalue['amazonstorepluginforwordpressoptions']))
{
$optionvalue['amazonstorepluginforwordpressoptions']='';
}
if(!isset($optionvalue['std']) || empty($optionvalue['std']))
{
$optionvalue['std']='';
}
$setmyamazonstorepluginforwordpressoptions[]=array("name" => $optionvalue['name'],
"id" => $optionvalue['id'],
"std" => $optionvalue['std'],
"type" => $optionvalue['type'],
"amazonstorepluginforwordpressoptions" => $optionvalue['amazonstorepluginforwordpressoptions']);
}
update_option($mythemeamazonstorepluginforwordpressoptions,$setmyamazonstorepluginforwordpressoptions);
}
}
function amazonstorepluginforwordpress_reconcile_options()
{
global $amazonstorepluginforwordpressoptionsprefix,$defamazonstorepluginforwordpressoptions;
$mythemeamazonstorepluginforwordpressoptions=$amazonstorepluginforwordpressoptionsprefix.'_options';
$amazonstorepluginforwordpressamazonstorepluginforwordpressoptions=get_amazonstorepluginforwordpressoptions();
$setmyamazonstorepluginforwordpressoptions=array();
foreach ($defamazonstorepluginforwordpressoptions as $optionvalue)
{
if(!isset($optionvalue['id']) || empty($optionvalue['id']))
{
$optionvalue['id']='';
}
if(!isset($optionvalue['amazonstorepluginforwordpressoptions']) || empty($optionvalue['amazonstorepluginforwordpressoptions']))
{
$optionvalue['amazonstorepluginforwordpressoptions']='';
}
if(!isset($optionvalue['name']) || empty($optionvalue['name']))
{
$optionvalue['name']='';
}
if(!isset($optionvalue['std']) || empty($optionvalue['std']))
{
$optionvalue['std']='';
}
if(isset($amazonstorepluginforwordpressamazonstorepluginforwordpressoptions[$optionvalue['id']]) && !empty($amazonstorepluginforwordpressamazonstorepluginforwordpressoptions[$optionvalue['id']]))
{
$savedoptionvalue=$amazonstorepluginforwordpressamazonstorepluginforwordpressoptions[$optionvalue['id']];
}
elseif(isset($optionvalue['std']) && !empty($optionvalue['std']))
{
$savedoptionvalue=$optionvalue['std'];
}
else
{
$savedoptionvalue='';
}
$setmyamazonstorepluginforwordpressoptions[]=array("name" => $optionvalue['name'],
"id" => $optionvalue['id'],
"std" => $savedoptionvalue,
"type" => $optionvalue['type'],
"amazonstorepluginforwordpressoptions" => $optionvalue['amazonstorepluginforwordpressoptions']);
}
update_option($mythemeamazonstorepluginforwordpressoptions,$setmyamazonstorepluginforwordpressoptions);
}
function amazonstorepluginforwordpress_admin() {
global $myasfwpname, $amazonstorepluginforwordpressoptionsprefix, $defamazonstorepluginforwordpressoptions;
amazonstorepluginforwordpress_reconcile_options();
//Begin the saving procedures
$mythemeamazonstorepluginforwordpressoptions=$amazonstorepluginforwordpressoptionsprefix.'_options';
$mysavedthemeamazonstorepluginforwordpressoptions=get_option($mythemeamazonstorepluginforwordpressoptions);
$amazonstorepluginforwordpressoptions = $mysavedthemeamazonstorepluginforwordpressoptions;
if (!isset($amazonstorepluginforwordpressoptions) || empty($amazonstorepluginforwordpressoptions) || !is_array($amazonstorepluginforwordpressoptions))
{
$amazonstorepluginforwordpressoptions = $defamazonstorepluginforwordpressoptions;
if($amazonstorepluginforwordpressoptions)
{
foreach ($amazonstorepluginforwordpressoptions as $optionvalue)
{
if(isset($optionvalue['id']) && !empty($optionvalue['id']))
{
$savedoptionvalue=get_option($optionvalue['id']);
if(!isset($savedoptionvalue) || empty ($savedoptionvalue))
{
$savedoptionvalue=$optionvalue['std'];
}
$setmyamazonstorepluginforwordpressoptions[]=array("name" => $optionvalue['name'],
"id" => $optionvalue['id'],
"std" => $savedoptionvalue,
"type" => $optionvalue['type'],
"amazonstorepluginforwordpressoptions" => $optionvalue['amazonstorepluginforwordpressoptions']);
delete_option($optionvalue['id']);
}
}
}
update_option($mythemeamazonstorepluginforwordpressoptions,$setmyamazonstorepluginforwordpressoptions);
}
if( isset($_REQUEST['action']) && ( 'updateamazonstorepluginforwordpressoptions' == $_REQUEST['action'] ))
{
$myoptionvalue='';
foreach ($amazonstorepluginforwordpressoptions as $optionvalue)
{
if(isset($optionvalue['id']) && !empty($optionvalue['id']))
{
if( isset( $_REQUEST[ $optionvalue['id'] ] ) )
{
$myoptionvalue = $_REQUEST[ $optionvalue['id'] ];
}
}
if(!isset($optionvalue['amazonstorepluginforwordpressoptions']) || empty($optionvalue['amazonstorepluginforwordpressoptions']))
{
$optionvalue['amazonstorepluginforwordpressoptions']='';
}
if(!isset($optionvalue['id']) || empty($optionvalue['id']))
{
$optionvalue['id']='';
}
if(!isset($optionvalue['std']) || empty($optionvalue['std'] ))
{
$optionvalue['std']='';
}
if($optionvalue['id'] == $amazonstorepluginforwordpressoptionsprefix.'_featuredcat'){
$optionvalue['amazonstorepluginforwordpressoptions']=$amazonstoreforwordpresscatdlist;}
$myamazonstorepluginforwordpressoptions[]=array("name" => $optionvalue['name'],
"id" => $optionvalue['id'],
"std" => $myoptionvalue,
"type" => $optionvalue['type'],
"amazonstorepluginforwordpressoptions" => $optionvalue['amazonstorepluginforwordpressoptions']);
}
update_option($mythemeamazonstorepluginforwordpressoptions,$myamazonstorepluginforwordpressoptions);
$amazonstorepluginforwordpressoptionsupdated=true;
}
else if( isset($_REQUEST['action']) && ( 'reset' == $_REQUEST['action'] ))
{
update_option($mythemeamazonstorepluginforwordpressoptions,$defamazonstorepluginforwordpressoptions);
$amazonstorepluginforwordpressoptionsreset=true;
}
//End the saving procedures
if( isset($_REQUEST['saved']) && !empty( $_REQUEST['saved'] )) echo '
'.$myasfwpname.' settings saved.
';
if ( isset($_REQUEST['reset']) && !empty( $_REQUEST['reset'] )) echo '
'.$myasfwpname.' settings reset.
';
$amazonstorepluginforwordpressamazonstorepluginforwordpressoptions=get_amazonstorepluginforwordpressoptions();
$amazonstorepluginforwordpresssavedamazonstorepluginforwordpressoptions = get_option($amazonstorepluginforwordpressoptionsprefix.'_options');
if (!isset($amazonstorepluginforwordpresssavedamazonstorepluginforwordpressoptions) || empty($amazonstorepluginforwordpresssavedamazonstorepluginforwordpressoptions) || !is_array($amazonstorepluginforwordpresssavedamazonstorepluginforwordpressoptions))
{
$amazonstorepluginforwordpressoptions = $defamazonstorepluginforwordpressoptions;
}
else
{
$amazonstorepluginforwordpressoptions=$amazonstorepluginforwordpresssavedamazonstorepluginforwordpressoptions;
}
?>
settings
";
$viewcartheader=$aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_viewcartheader'];
if(!isset($viewcartheader) || empty($viewcartheader))
{
$viewcartheader=__("Your Shopping Cart Contents");
}
_e("$viewcartheader");
echo "
";
global $post;
$itemspostidsinclude=join(',',$itemarrayforsum2);
$myposts = get_posts('include='.$itemspostidsinclude);
$valuesforsubtotal=array();
foreach($myposts as $post) :
?>
: "/>
" class="updatebutton">
ID, "aspfwpnewprice", $single = true)){ $price=get_post_meta($post->ID, "aspfwpnewprice", $single = true); echo "
Unit Price: "; $price=str_replace('$','',$price); $price=(float)$price; echo $aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_currencysymbol']; echo " $price"; echo "
"; echo "
Total Price: "; $price=str_replace('$','',$price); $price=(float)$price; $recalcprice=($price*$numberofitems); echo $aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_currencysymbol']; echo " $recalcprice"; $valuesforsubtotal[]=$recalcprice; echo "
"; } ?>
Sub Total: ";
echo $aspfwpops[$amazonstorepluginforwordpressoptionsprefix.'_currencysymbol'];
echo "
";
$instacartsubtotal=array_sum($valuesforsubtotal);
echo $instacartsubtotal;
echo " ";
echo "";
aspfwp_configure_checkout_link();
echo " ";
echo " ";
echo "";
}
else
{
_e("Your shopping cart is empty");
}
}
function aspfwp_single_template_code()
{global $amazonstorepluginforwordpress_plugin_url,$aspfwp_pageid,$permalinkstructure;
$aspfwp_permalink=get_permalink($aspfwp_pageid);
if(!isset($permalinkstructure) || empty($permalinkstructure)){ $querysymbol="&";} else { $querysymbol="?";}
?>