"General Settings",
"type" => "heading"),
array( "name" => "Amazon Affiliate ID",
"desc" => "Your Amazon Affiliate ID
",
"id" => $shortname_apipp."_amazon_associateid",
"type" => "text"),
array( "name" => "Your Amazon Locale/Region",
"desc" => "The Locale to use for Amazon API Calls (ca,com,co.uk,de,fr,jp) Default is 'com' for US.
",
"id" => $shortname_apipp."_amazon_locale",
"type" => "select",
"options" => array(
"0" => array("value" => "com","text" => "US (default)"),
"1" => array("value" => "ca","text" => "Canada"),
"2" => array("value" => "co.uk","text" => "United Kingdom"),
"3" => array("value" => "de","text" => "Germany"),
"4" => array("value" => "fr","text" => "France"),
"5" => array("value" => "jp","text" => "Japan")
)),
array( "name" => "Use My Custom Styles?",
"desc" => "If you want to use your own styles, check this box and enter them below.
",
"id" => $shortname_apipp."_product_styles_mine",
"type" => "checkbox"),
array( "name" => "Product Styles",
"desc" => "Your Custom styles can go here.
",
"id" => $shortname_apipp."_product_styles",
"type" => "textareabig"),
);
// Functions
function apipp_options_add_subpage(){
global $fullname_apipp, $shortname_apipp, $options_apipp;
apipp_options_admin_page($fullname_apipp, $shortname_apipp, $options_apipp);
}
function apipp_options_add_admin_page($themename,$shortname,$options) {
if ( basename(__FILE__) == 'amazon-product-in-a-post-options.php' ) {
if ( 'save' == $_REQUEST['action'] && $_REQUEST[$shortname.'_option']== $shortname ) {
foreach ($options as $value) {
if($value['type'] != 'multicheck'){
update_option( $value['id'], $_REQUEST[ $value['id'] ] );
}else{
foreach($value['options'] as $mc_key => $mc_value){
$up_opt = $value['id'].'_'.$mc_key;
update_option($up_opt, $_REQUEST[$up_opt] );
}
}
}
foreach ($options as $value) {
if($value['type'] != 'multicheck'){
if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); }
}else{
foreach($value['options'] as $mc_key => $mc_value){
$up_opt = $value['id'].'_'.$mc_key;
if( isset( $_REQUEST[ $up_opt ] ) ) { update_option( $up_opt, $_REQUEST[ $up_opt ] ); } else { delete_option( $up_opt ); }
}
}
}
header("Location: admin.php?page=".$shortname."_plugin_admin&saved=true");
die;
} else if( 'reset' == $_REQUEST['action'] && $_REQUEST[$shortname.'_option']== $shortname ) {
foreach ($options as $value) {
if($value['type'] != 'multicheck'){
delete_option( $value['id'] );
}else{
foreach($value['options'] as $mc_key => $mc_value){
$del_opt = $value['id'].'_'.$mc_key;
delete_option($del_opt);
}
}
}
header("Location: admin.php?page=".$shortname."_plugin_admin&reset=true");
die;
}
}
}
function apipp_options_admin_page($themename, $shortname, $options) {
if ( $_REQUEST['saved'] ) echo '
'.$themename.' settings saved.
'.$themename.' settings reset.