Author Topic: suggestions and help  (Read 1694 times)

Anonymous

  • Guest
suggestions and help
« on: September 24, 2008, 05:45:17 PM »
Great idea for the plugin!

See it in action with edits so far here: http://http://www.baby.lench.us/?page_id=41 and my personal site is (insert shamless plug) here:http://http://www.daniellench.com (still in progress, the header image isn't right yet).
Our baby is due in may and I wanted to put an amazon wish list on my site for the ease of one stop shopping. Your plugin is the best one out there and I want to help make it better.

How 'bout these edits in the shortcode because my theme for the baby site doesn't handle widgets well. I wanted to show the item picture and the content together so I edited the avh-amazon.shortcode.php

edits to the function shortcodeAsin:
Code: [Select]

case 'pic-text' :
$imgsrc = $item_result['Items']['Item']['SmallImage']['URL'];
$return = '<table style=" border: none; cellpadding: 2px; align: left"><tr><td><a title="' . $content . '" href="' . $myurl . '"><img class="alignleft" src="' . $imgsrc . '" alt="' . $content . '"/></a></td><td><a title="' . $content . '" href="' . $myurl . '">' . $content . '</a></td></tr></table>';
break;

Had to add the tables because the items were nesting when there are multiples and the background was ending prematurely.


edits to the function metaboxTabOutputOptions:
Code: [Select]
echo '<label><input type="radio" value="pic" id="avhamazon_sc' . $tabid . '_linktypep" name="avhamazon_sc' . $tabid . '_linktype"/> ' . __ ( 'Picture', 'avhamazon' ) . '</label><br />';
echo '<label><input type="radio" value="pic-text" id="avhamazon_sc' . $tabid . '_linktypept" name="avhamazon_sc' . $tabid . '_linktype"/> ' . __ ( 'Picture and Text', 'avhamazon' ) . '</label></p>';
Changed the </p> to <br /> at the end of the _linktypep line above and added </p> to the end of the new line.




I'm not so good at coding so I can't figure out how to show all items at once and I had to insert each item into the editor.
The post in the editor looks exactly like this:[avhamazon wishlist="ZS4YOCPN2JT6" asin="B000UEA9ZW" linktype="pic-text" locale="US"][avhamazon wishlist="ZS4YOCPN2JT6" asin="B000LPBQC0" linktype="pic-text" locale="US"]

It must be a "while have items(get items)" or something like the wordpress loop to get all items in the wishlist.



Lastly I was trying to pull the wish list from the database to be the default value in the input box but I'm lost completely. I think it is retrieved at the beginning.
Code: [Select]
// Get options from WP
$this->db_options = 'avhamazon';
$options_from_table = get_option ( $this->db_options );
But like I said, I'm lost.


It should be an edit to the value="" in the function metaboxTabWishlist:
Code: [Select]
//can't figure this out
echo ' <input style="width: 13em" type="text" value="' . $this->info['wishlist_id'] . '" id="avhamazon_scwishlist_wishlist" name="avhamazon_scwishlist_wishlist" autocomplete="on"/>';
//i want the default wishlist populated


I'll keep your associate ID for the purchases because it's not pulling it from the database correctly.

I changed it from yours in the admin panel but it doesn't pass into the shortcode:
Code: [Select]
// Update default options by getting not empty values from options table
foreach ( ( array ) $default_options as $default_options_name => $default_options_value ) {
if ( ! is_null ( $options_from_table[$default_options_name] ) ) {
if ( is_int ( $default_options_value ) ) {
$default_options[$default_options_name] = ( int ) $options_from_table[$default_options_name];
} else {
$default_options[$default_options_name] = $options_from_table[$default_options_name];
if ( 'associated_id' == $default_options_name ) {
if ( 'blogavirtualh-20' == $options_from_table[$default_options_name] ) $default_options[$default_options_name] = 'avh-amazon-20'; // Changed the Amazon ID for better tracking
}
}
}
}

What do you think, and thanks again.


Dan

Anonymous

  • Guest
Re: suggestions and help
« Reply #1 on: September 24, 2008, 05:48:49 PM »
also, do you know Jessica van der Steen?

sorry i couldn't resist, my great great g-pa  shortened his name from lenchitsky and ever since i found out I've been fascinated with cool names.

dan

Peter

  • Administrator
  • Regular
  • *****
  • Posts: 439
    • http://blog.avirtualhome.com
Re: suggestions and help
« Reply #2 on: September 24, 2008, 07:05:24 PM »
First congrats on the upcoming baby.
Second I'm glad to read you like my plugin,
Third I don't know a Jessica van der Steen, it sounds Dutch and probably she is as well. I'm from the Netherlands myself, moved to the States about 4 years ago.

Hmm, it seems you stumble upon a bug, because the content should be shown when a a shortcode is used with a picture. (Whoops my mistake, it was setup to show no text)
I'll see if I can create something for you that creates an entire page with all the items. If that's what you are looking for, let me know.

The default wishlist is something I have planned for the next release and with the bug you discovered it might get in a bit quicker :)

Edit:
 (Whoops my mistake, it was setup to show no text)
Peter van der Does
AVH Plugins developer

Peter

  • Administrator
  • Regular
  • *****
  • Posts: 439
    • http://blog.avirtualhome.com
Re: suggestions and help
« Reply #3 on: September 24, 2008, 09:02:49 PM »
All right I have a patch for you that you integrate in avh-amazon.shortcode.php, this will process all items from the wishlist.

Code: [Select]
// If a random item is wanted, fill $attrs['asin'] with an ASIN from the wishlist
if ( 'random' == strtolower ( $attrs['asin'] ) ) {
$Item_keys = avh_getItemKeys ( $list_result['Lists']['List']['ListItem'] );
foreach ( $Item_keys as $value ) {
$Item = $list_result['Lists']['List']['ListItem'][$value];
}
$attrs['asin'] = $Item['Item']['ASIN'];
}

if ( 'all' == strtolower($attrs['asin'])) {
foreach ($list_result['Lists']['List']['ListItem'] as $key => $value) {
$attrs['asin'] = $value['Item']['ASIN'];
list ( $oneresult, $error ) = $this->shortcodeAsin ( &$proxy, $attrs, $content, $associatedid );
$result .= $oneresult.'<br />';
}
$attrs['asin'] = null;
}

You'll have to change the shortcode by hand to read the following:
Code: [Select]
[avhamazon wishlist="ZS4YOCPN2JT6" asin="all" linktype="pic-text" locale="US"]
I'll add the above patch into the production code, with the next update this will be in there.
Peter van der Does
AVH Plugins developer

Anonymous

  • Guest
Re: suggestions and help
« Reply #4 on: September 26, 2008, 12:25:27 PM »
nicely done, and simpler than i thought.
http://http://www.baby.lench.us/?page_id=41

works perfectly!

also a question, does the cache update only when a page or post is saved or at an interval. i am resaving the page to force the wishlist to update. i do not have the wp-cache active or any other caching active.

thanks again peter for your help and plugin.
 i added the avh-amazon-20 tag to the direct link on the page as well.

i'm still poking around and thinking about things with the site and the wishlist, i'll post updates and keep checking in regularly.

dan
drlench@gmail.com

my current shortcode.php file:

Code: [Select]
<?php
class AVHAmazonShortcode {

var $version;

var $info;

var $options;

var $default_options;

var $db_options;

var $locale_table;

/**
 * PHP4 Constructor
 *
 * @param array $default_options
 * @param string $version
 * @param array $info
 * @param array $locale_table
 *
 * @return AVHAmazonShortcode
 */
function AVHAmazonShortcode $default_options = array(), $version ''$info = array(), $locale_table = array() ) {

// Load version number
$this->version $version;
unset ( $version );

// Set class property for default options
$this->default_options $default_options;

// Get options from WP
$this->db_options 'avhamazon';
$options_from_table get_option $this->db_options );

// Update default options by getting not empty values from options table
foreach ( ( array ) $default_options as $default_options_name => $default_options_value ) {
if ( ! is_null $options_from_table[$default_options_name&#93; ) ) {
if ( is_int $default_options_value ) ) {
$default_options[$default_options_name&#93; = ( int ) $options_from_table[$default_options_name&#93;;
} else {
$default_options[$default_options_name&#93; = $options_from_table[$default_options_name&#93;;
if ( 'associated_id' == $default_options_name ) {
if ( 'blogavirtualh-20' == $options_from_table[$default_options_name&#93; ) $default_options[$default_options_name&#93; = 'avh-amazon-20'; // Changed the Amazon ID for better tracking
}
}
}
}

// Set the class property and unset no used variable
$this->options $default_options;
unset ( $default_options );
unset ( $options_from_table );
unset ( $default_options_value );

// Get info data from constructor
$this->info $info;
unset ( $info );

// Set locale Tables
$this->locale_table $locale_table;

// Set the actions, filters and shortcode&#46;
add_action 'admin_menu', array ( &$this'handleAdminMenu' ) );
add_action 'wp_ajax_avhamazon_metabox', array ( &$this'on_wp_ajax_avhamazon_metabox' ) ); // New function for AJAX calls from the submit button&#46;
add_filter 'admin_print_scripts', array ( &$this, 'adminHead' ) ); // Runs in the HTML header so a plugin can add JavaScript scripts to all admin pages&#46;
add_shortcode 'avhamazon', array ( &$this'handleShortcode' ) );
}

/**
 * Add the metabox to the administration pages Post and Page
 *
 */
function handleAdminMenu () {

add_meta_box 'avhamazonmetabox01''AVH Amazon Short Code', array ( &$this'createMetabox' ), 'post''normal' );
add_meta_box 'avhamazonmetabox01''AVH Amazon Short Code', array ( &$this'createMetabox' ), 'page''normal' );
}

/**
 * Add the javascript to all admin pages&#46;
 *
 */
function adminHead () {

if ( $GLOBALS['editing'&#93; ) { //@todo Check if there's a better solution for this&#46;
wp_enqueue_script 'avhamazonmetabox'$this->info['install_url'&#93; &#46; '/inc/js/metabox&#46;js', array ( 'jquery' ), $this->version );
}
}

/**
 * Handle the shortcode
 *
 * [avhamazon asin= locale= linktype= wishlist&#93;content[/avhamazon&#93;
 *
 */
function handleShortcode $atts$content null ) {

global $avhamazon;

$result '';
$error '';
$attrs shortcode_atts ( array (
'asin' => '',
'locale' => 'US',
'linktype' => 'text',
'wishlist' => '' ), $atts );

$locale $attrs['locale'&#93;;

// Get the associate ID
$associatedid avh_getAssociateId $locale );

/**
 * Set up WSDL Cache
 */
$avhamazon->wsdlurl $avhamazon->wsdlurl_table[$locale&#93;;
$cache = new wsdlcache $avhamazon->wsdlcachefolder); // Cache it indefinitely
$avhamazon->wsdl $cache->get $avhamazon->wsdlurl );
if ( is_null $avhamazon->wsdl ) ) {
$avhamazon->wsdl = new wsdl $avhamazon->wsdlurl );
$cache->put $avhamazon->wsdl );
} else {
$avhamazon->wsdl->debug_str '';
$avhamazon->wsdl->debug 'Retrieved from cache' );
}

/**
 * Create SOAP Client
 */
$client = new nusoap_client $avhamazon->wsdltrue );
$client->soap_defencoding 'UTF-8';
$proxy $client->getProxy ();

if ( $attrs['wishlist'&#93; ) {
$list_result avh_getListResults $attrs['wishlist'&#93;, $proxy );
if ( $list_result['Lists'&#93;['Request'&#93;['Errors'&#93; ) {
$error 'WishList ' &#46; $attrs['wishlist'&#93; &#46; ' doesn't exists';
$attrs['asin'&#93; = null;
}
}

// If a random item is wanted, fill $attrs['asin'&#93; with an ASIN from the wishlist
if ( 'random' == strtolower $attrs['asin'&#93; ) ) {
$Item_keys avh_getItemKeys $list_result['Lists'&#93;['List'&#93;['ListItem'&#93; );
foreach ( $Item_keys as $value ) {
$Item $list_result['Lists'&#93;['List'&#93;['ListItem'&#93;[$value&#93;;
}
$attrs['asin'&#93; = $Item['Item'&#93;['ASIN'&#93;;
}

if ( 'all' == strtolower($attrs['asin'&#93;)) {
        
foreach ($list_result['Lists'&#93;['List'&#93;['ListItem'&#93; as $key => $value) {
            
$attrs['asin'&#93; = $value['Item'&#93;['ASIN'&#93;;
            
list ( $oneresult$error ) = $this->shortcodeAsin ( &$proxy$attrs$content$associatedid );
            
$result &#46;= $oneresult&#46;'<br />';
         
}
         
$attrs['asin'&#93; = null;
}

if ( $attrs['asin'&#93; ) {
list ( $result$error ) = $this->shortcodeAsin ( &$proxy$attrs$content$associatedid );
}

if ( $error ) {
$return '<strong>avhamazon error&#58;' &#46; $error &#46; '</strong>';
} else {
$return $result;
}
return ($return);
}

/**
 * Create the output for the shortcode
 *
 * @param array $proxy
 * @param array $attrs
 * @param string $content
 * @param string $associatedid
 * @return array $return and $error, if and error occurs the error variable is used and return will be empty&#46;
 */
function shortcodeAsin $proxy$attrs$content$associatedid ) {

$error '';
$item_result $proxy->ItemLookup avh_getSoapItemLookupParams $attrs['asin'&#93;, $associatedid ) );
if ( $item_result['Items'&#93;['Request'&#93;['Errors'&#93; ) {
$return '';
$error 'Item with ASIN ' &#46; $attrs['asin'&#93; &#46; ' doesn't exist';
} else {
$pos strpos $item_result['Items'&#93;['Item'&#93;['DetailPageURL'&#93;, $attrs['asin'&#93; );

$myurl substr $item_result['Items'&#93;['Item'&#93;['DetailPageURL'&#93;, 0, $pos + strlen ( $attrs['asin'&#93; ) );
// If a wishlist is given, make sure when somebody clicks on the link, Amazon knows the List owner&#46;
if ( $attrs['wishlist'&#93; ) {
$myurl &#46;= '/ref=wl_it_dp?ie=UTF8&colid=' &#46; $attrs['wishlist'&#93;;
}
$myurl &#46;= '&tag=' &#46; $associatedid;

// If no content is given we use the Title from Amazon&#46;
$content = ($content) ? $content &#58; $item_result['Items'&#93;['Item'&#93;['ItemAttributes'&#93;['Title'&#93;;

switch ( $attrs['linktype'&#93; ) {
case 'text' &#58;
$return '<a title="' &#46; $content &#46; '" href="' &#46; $myurl &#46; '">' &#46; $content &#46; '</a>';
break;
case 'pic' &#58;
$imgsrc $item_result['Items'&#93;['Item'&#93;['SmallImage'&#93;['URL'&#93;;
$return '<a title="' &#46; $content &#46; '" href="' &#46; $myurl &#46; '"><img class="alignleft" src="' &#46; $imgsrc &#46; '" alt="' &#46; $content &#46; '"/></a>';
break;
//begin //could be a cleaner way but the items nest without the tables
case 'pic-text' &#58;
$imgsrc $item_result['Items'&#93;['Item'&#93;['SmallImage'&#93;['URL'&#93;;
$return '<table style=" border&#58; none; cellpadding&#58; 2px; align&#58; left"><tr><td><a title="' &#46; $content &#46; '" href="' &#46; $myurl &#46; '"><img class="alignleft" src="' &#46; $imgsrc &#46; '" alt="' &#46; $content &#46; '"/></a></td><td><a title="' &#46; $content &#46; '" href="' &#46; $myurl &#46; '">' &#46; $content &#46; '</a></td></tr></table>';
break;
//end
default &#58;
$return '<a title="' &#46; $content &#46; '" href="' &#46; $myurl &#46; '">' &#46; $content &#46; '</a>';
break;
}
}
return array (
$return,
$error );
}

/**
 * Create the metabox
 *
 */
function createMetabox () {

//@todo Use of the nonce field for security
//wp_nonce_field( 'avhamazon-metabox', '_ajax_nonce', false );
$locale "US";

echo '<ul id="avhamazon_tabs" class="ui-tabs-nav">';
echo '<input name="avhamazon_mb_url" id="avhamazon_mb_url" value="' &#46; $this->info['siteurl'&#93; &#46; '" type="hidden" />';

// The tabs
echo '<li class="ui-tabs-selected"><a href="#avhamazon_tab_wishlist">' &#46; __ ( 'Wishlist', 'avhamazon' ) &#46; '</a></li>';
echo '<li class=""><a href="#avhamazon_tab_asin">' &#46; __ ( 'ASIN', 'avhamazon' ) &#46; '</a></li></ul>';

$this->metaboxTabWishlist ($locale);
$this->metaboxTabAsin ($locale);
}

/**
 * HTML for the Wishlist Tab
 *
 * @param string $locale
 *
 */
function metaboxTabWishlist ($locale) {

echo '<div id="avhamazon_tab_wishlist" class="ui-tabs-panel">';
echo ' <div id="avhamazon-wishlist-show">';
echo ' <p>';
echo ' <label style="display&#58;block">' &#46; __ ( 'Wish List ID&#58;', 'avhamazon' );
echo ' <input style="width&#58; 13em" type="text" value="" id="avhamazon_scwishlist_wishlist" name="avhamazon_scwishlist_wishlist" autocomplete="on"/>';
//can't figure this out
// echo ' <input style="width&#58; 13em" type="text" value="' &#46; $this->info['wishlist_id'&#93; &#46; '" id="avhamazon_scwishlist_wishlist" name="avhamazon_scwishlist_wishlist" autocomplete="on"/>';
//i want the default wishlist populated
echo ' </label>';
echo ' <label style="display&#58;block">' &#46; __ ( 'Locale Amazon&#58;', 'avhamazon' );
echo ' <select id="avhamazon_scwishlist_locale" name="avhamazon_scwishlist_locale" />';
$seldata '';
foreach ( $this->locale_table as $key => $value ) {
$seldata &#46;= '<option value="' &#46; $key &#46; '" ' &#46; (($locale == $key) ? 'selected="selected"' &#58; '') &#46; ' >' &#46; $value &#46; '</option>' &#46; "n";
}
echo $seldata;
echo ' </select></label>';
echo ' <br />';
echo ' <input class="button-secondary" type="submit" value="Show Items" id="avhamazon_submit_wishlist" name="avhamazon_submit_wishlist" />';
echo ' </p>';
echo ' </div>';
echo ' <div id="avhamazon_wishlist_output"></div>';
echo '</div>';
}

/**
 * HTML for the ASIN tab
 *
 * @param string $locale
 *
 */
function metaboxTabAsin ($locale) {

echo '<div id="avhamazon_tab_asin" class="ui-tabs-panel">';
echo ' <div id="avhamazon_asin_show">';
echo ' <p>';
echo ' <label style="display&#58;block">' &#46; __ ( 'ASIN', 'avhamazon' );
echo ' <input type="text" value="" style="style="width&#58; 13em";" id ="avhamazon_asin_nr" name="avhamazon_asin_nr" autocomplete="on"/>';
echo ' </label>';
echo ' <label style="display&#58;block">' &#46; __ ( 'Locale Amazon&#58;', 'avhamazon' );
echo ' <select id="avhamazon_scasin_locale" name="avhamazon_scasin_locale" />';
$seldata '';
foreach ( $this->locale_table as $key => $value ) {
$seldata &#46;= '<option value="' &#46; $key &#46; '" ' &#46; (($locale == $key) ? 'selected="selected"' &#58; '') &#46; ' >' &#46; $value &#46; '</option>' &#46; "n";
}
echo $seldata;
echo ' </select></label>';
echo ' <br />';
echo ' <input class="button-secondary" type="button" value="Show Item" id="avhamazon_submit_asin" name="avhamazon_submit_asin" />';
echo ' </p>';
echo ' </div>';
echo ' <div id="avhamazon_asin_output"></div>';
echo '</div>';
}

/**
 * The AJAX function called when the submit button is clicked&#46; The call to admin-ajax&#46;php is done through javascript in metabox&#46;js
 *
 */
function on_wp_ajax_avhamazon_metabox () {

//@todo Use of the nonce for security
//check_ajax_referer ( 'avhamazon-metabox', '_ajax_nonce' );
echo '<script type="text/javascript">';
echo 'var avhamazon = new avhamazonmetabox();';
echo '</script>';
$action $_POST['avhamazon_mb_action'&#93;;
$values $_POST['avhamazon_mb_values'&#93;;

switch ( $action ) {
case 'wishlist' &#58;
$this->metaboxTabWishlistOutput $values );
break;
case 'asin' &#58;
$this->metaboxTabAsinOutput $values );
break;
}
}

/**
 * Get and show the results for the Wishlist tab
 *
 * @param array $values We get them from the javascript call&#46;
 */
function metaboxTabWishlistOutput $values ) {

global $avhamazon;

$wishlist $values[0&#93;;
$locale $values[1&#93;;

/**
 * Set up WSDL Cache
 */
$avhamazon->wsdlurl $avhamazon->wsdlurl_table[$locale&#93;;
$cache = new wsdlcache $avhamazon->wsdlcachefolder); // Cache it indefinitely
$avhamazon->wsdl $cache->get $avhamazon->wsdlurl );
if ( is_null $avhamazon->wsdl ) ) {
$avhamazon->wsdl = new wsdl $avhamazon->wsdlurl );
$cache->put $avhamazon->wsdl );
} else {
$avhamazon->wsdl->debug_str '';
$avhamazon->wsdl->debug 'Retrieved from cache' );
}

/**
 * Create SOAP Client
 */
$client = new nusoap_client $avhamazon->wsdltrue );
$client->soap_defencoding 'UTF-8';
$proxy $client->getProxy ();

$list_result avh_getListResults $wishlist$proxy );
$total_items count $list_result['Lists'&#93;['List'&#93;['ListItem'&#93; );
if ( $total_items ) {
$this->metaboxTabOutputHeader ();
$listitem $list_result['Lists'&#93;['List'&#93;['ListItem'&#93;;
foreach ( $listitem as $key => $value ) {
$Item $value;
$item_result $proxy->ItemLookup avh_getSoapItemLookupParams $Item['Item'&#93;['ASIN'&#93;, '' ) );
$this->metaboxTabOutputItem $item_result['Items'&#93;['Item'&#93;['ItemAttributes'&#93;['Title'&#93;, $Item['Item'&#93;['ASIN'&#93;, 'avhamazon_scwishlist_asin-' &#46; $key, 'avhamazon_scwishlist_asin', '', ('0' == $key) ? TRUE &#58; FALSE );
}
// Display the last row as a randomizing option
$this->metaboxTabOutputItem __('Randomize the items','avhamazon'), 'random''avhamazon_scwishlist_asin-random''avhamazon_scwishlist_asin'''FALSE );
$this->metaboxTabOutputOptions 'wishlist' );
$this->metaboxTabOutputSendtoeditor 'wishlist' );
} else {
echo '<strong>' &#46; __ ( 'Can't find the given wish list', 'avhamazon' ) &#46; '</strong>';
}
}

/**
 * Get and show the results for the ASIN tab
 *
 * @param array $values We get them from the javascript call&#46;
 */
function metaboxTabAsinOutput $values ) {

global $avhamazon;

$asin $values[0&#93;;
$locale $values[1&#93;;
$wsdlurl $avhamazon->wsdlurl_table[$locale&#93;;

/**
 * Set up WSDL Cache
 */
$avhamazon->wsdlurl $avhamazon->wsdlurl_table[$locale&#93;;
$cache = new wsdlcache $avhamazon->wsdlcachefolder); // Cache it indefinitely
$avhamazon->wsdl $cache->get $avhamazon->wsdlurl );
if ( is_null $avhamazon->wsdl ) ) {
$avhamazon->wsdl = new wsdl $avhamazon->wsdlurl );
$cache->put $avhamazon->wsdl );
} else {
$avhamazon->wsdl->debug_str '';
$avhamazon->wsdl->debug 'Retrieved from cache' );
}

/**
 * Create SOAP Client
 */
$client = new nusoap_client $wsdlurltrue );
$client->soap_defencoding 'UTF-8';
$proxy $client->getProxy ();
$item_result $proxy->ItemLookup avh_getSoapItemLookupParams $asin'' ) );
if ( $item_result['Items'&#93;['Request'&#93;['Errors'&#93; ) {
echo '<strong>' &#46; __ ( 'Can't find the given item', 'avhamazon' ) &#46; '</strong>';
} else {
$this->metaboxTabOutputHeader ();
$this->metaboxTabOutputItem $item_result['Items'&#93;['Item'&#93;['ItemAttributes'&#93;['Title'&#93;, $asin, 'avhamazon_scasin_asin', 'avhamazon_scasin_asin', '', TRUE );
$this->metaboxTabOutputOptions 'asin' );
$this->metaboxTabOutputSendtoeditor 'asin' );
}
}

/**
 * Print the header for the result
 *
 */
function metaboxTabOutputHeader () {

echo '<strong>' &#46; __ ( 'Select item', 'avhamazon' ) &#46; '</strong><br />';
}

/**
 * Display a row
 *
 * @param string $title
 * @param string $asin
 * @param string $id
 * @param string $name
 * @param string $class
 * @param boolean $checked
 */
function metaboxTabOutputItem $title$asin$id$name$class ''$checked FALSE ) {

$class = ($class) ? 'class="' &#46; $class &#46; '"' &#58; '';
echo '<label ' &#46; $class &#46; '><input type="radio" value="' &#46; $asin &#46; '" id="' &#46; $id &#46; '" name="' &#46; $name &#46; '"' &#46; ($checked ? ' checked="checked" ' &#58; "") &#46; ' /> ' &#46; $title &#46; '</label><br />';
}

/**
 * Display the general options after the row(s) of item(s)
 *
 * @param string $tabid (wishlist/asin)
 */
function metaboxTabOutputOptions $tabid ) {

echo '<p><strong>' &#46; __ ( 'Link type&#58;', 'avhamazon' ) &#46; '</strong><br/>';
echo '<label><input type="radio" value="text" id="avhamazon_sc' &#46; $tabid &#46; '_linktypet" checked="checked" name="avhamazon_sc' &#46; $tabid &#46; '_linktype"/> ' &#46; __ ( 'Text', 'avhamazon' ) &#46; '</label><br />';
//begin
echo '<label><input type="radio" value="pic" id="avhamazon_sc' &#46; $tabid &#46; '_linktypep" name="avhamazon_sc' &#46; $tabid &#46; '_linktype"/> ' &#46; __ ( 'Picture', 'avhamazon' ) &#46; '</label><br />';
echo '<label><input type="radio" value="pic-text" id="avhamazon_sc' &#46; $tabid &#46; '_linktypept" name="avhamazon_sc' &#46; $tabid &#46; '_linktype"/> ' &#46; __ ( 'Picture and Text', 'avhamazon' ) &#46; '</label></p>';
//end
echo '<p><label><strong>' &#46; __ ( 'Content&#58;', 'avhamazon' ) &#46; '</strong>';
echo '<input type="text" style="width&#58; 98%" id="avhamazon_sc' &#46; $tabid &#46; '_content" name="avhamazon_sc' &#46; $tabid &#46; '_content"/></p>';
}

/**
 * Show the send to editor button
 *
 * @param string $tabid (wishlist/asin)
 */
function metaboxTabOutputSendtoeditor $tabid ) {

echo '<p class="submit">';
echo '<input type="button" id="avhamazon_sendtoeditor" name="' &#46; $tabid &#46; '" value="' &#46; __ ( 'Send to Editor', 'avhamazon' ) &#46; '" />';
echo '</p>';
}
}
?>

Peter

  • Administrator
  • Regular
  • *****
  • Posts: 439
    • http://blog.avirtualhome.com
Re: suggestions and help
« Reply #5 on: September 26, 2008, 01:39:25 PM »
Thank you adding me to your direct  link, I appreciate that a lot.

I'm not sure what you mean with "cache update" so I'll explain the process of the plugin a bit :)

If you refer the
Code: [Select]
$cache = new wsdlcache ( $avhamazon->wsdlcachefolder, 0 ); // Cache it indefinitely in the code, this is a cache for the WSDL file from Amazon. Instead of getting the file from Amazon at every request I cache it locally to save bandwidth and time.
WSDL stands for Web Services Description Language, and it's an XML document that describes a Web service, like Amazon. It specifies the location of the service and the operations and methods the service has, like LookUpItem for example.
This caching doesn't effect the calls, like the ItemLookup, etc made to Amazon.

The shortcode that's embedded in your page isn't processed by WordPress until the page is shown in a browser.
When you add items to your wishlist in Amazon, you don't have to do anything in WordPress. Sometimes it can take a few minutes before an item will show up but that's at Amazon's side.

I hope it explains it a bit.
Any suggestions are welcome of course. I just started on the next release v2.2, it will mostly have some enhancements in the backend, your suggestions will be incorporated as wll, like a default wishlist for the shortcode.
Peter van der Does
AVH Plugins developer