'; _e("Error"); echo ': '; _e('tracking ID not set' ); echo '.

'; } echo $after_widget; } /** * Widget setting pre update script * * @param array $new_instance * @param array $old_instance * @return array */ function update($new_instance, $old_instance) { $instance = $new_instance; $instance['linkColour'] = Widget_Amazon_Product_Ads::_validateColour( $new_instance['linkColour'] ); return $instance; } /** * Definte which type of ad is to be displayed and create the content * * @param array $instance */ function _content( $instance ) { global $post; //Check if a specific product has been specified if ( $instance['fixedProductId'] != "" ) { $this->ASIN = $instance['fixedProductId']; } else { //Grab the value of any ASIN/ISBN defined in the post $ASIN = get_post_meta( $post->ID, 'ASIN', true ); $ASIN = ( $ASIN ) ? $ASIN : get_post_meta( $post->ID, 'ISBN', true ); $this->ASIN = $ASIN; } if ( ( $this->ASIN ) && ( $instance['selfOptOnly'] != 'on' ) ){ Widget_Amazon_Product_Ads::_product( $instance ); } else { Widget_Amazon_Product_Ads::_context( $instance ); } } /** * Create product specific ad * * @param array $instance */ function _product( $instance ) { $store = $instance['store']; $trackingId = $instance['trackingId']; $linkColour = ( $instance['linkColour'] == '' ) ? '0000FF' : $instance['linkColour']; $domain["co.uk"] = "rcm-uk.amazon.co.uk"; $domain["com"] = "rcm.amazon.com"; $o["com"] = 1; $o["co.uk"] = 2; $sizeBits = preg_split("/x/", $instance['size'], 2); $w = ( intval( $sizeBits[0] ) > 0 ) ? intval( $sizeBits[0] ) : 120; $h = ( intval( $sizeBits[1] ) > 0 ) ? intval( $sizeBits[1] ) : 240; $arrASIN = explode(",", $this->ASIN); foreach ( $arrASIN as $ASIN ) { print ''; } } /** * Create self optimizing ads * * @param array $instance */ function _context( $instance ) { $store = $instance['store']; $trackingId = $instance['trackingId']; $sizeBits = preg_split("/x/", $instance['size'], 2); $w = ( intval( $sizeBits[0] ) > 0 ) ? intval( $sizeBits[0] ) : 120; $h = ( intval( $sizeBits[1] ) > 0 ) ? intval( $sizeBits[1] ) : 240; print ' '; } /** * Validate given colour and a valid hex RGB colour * * @param string $colour * @return string */ function _validateColour( $colour ) { if ( preg_match( '/^([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/', $colour ) == 0 ) { $validatedColour= ""; } else if ( preg_match( '/^([a-fA-F0-9]{3})$/', $colour ) == 1 ){ $validatedColour= substr( $colour, 0, 1 ); $validatedColour.= substr( $colour, 0, 1 ); $validatedColour.= substr( $colour, 1, 1 ); $validatedColour.= substr( $colour, 1, 1 ); $validatedColour.= substr( $colour, 2, 1 ); $validatedColour.= substr( $colour, 2, 1 ); } else { $validatedColour = $colour; } $validatedColour= strtoupper( $validatedColour); return $validatedColour; } } ?>