<?php echocurrent_apo_zone($zone_id, $echocurrent_id, $zone_style, $options); ?> to your template, or 3) as shortcode in a post with [echocurrent_apo_zone zone_id="0123456789" echocurrent_id="your-id-here" zone_style="fullBanner"]. For more detail about adding a zone to your WordPress blog, please see our documentation. * Version: 1.1 * Author: EchoCurrent Software, Inc. * Author URI: http://www.echocurrent.com */ /* * TODO: FILL IN THIS COPYWRITE SECTION */ // Admin form callback function. Will provide a simple form allowing the blog master to manage the options (such as EchoCurrent customer key and zone style function echocurrent_affiliate_control() { $possible_zone_styles = array( 'rectangleText' => 'Rectangle Text (180 x 150)', 'mediumRectangleText' => 'Medium Rectangle Text (300 x 250)', 'verticalRectangleText' => 'Vertical Rectangle Text (240 x 400)', 'fullBanner' => 'Full Banner (468 x 60)', 'halfBanner' => 'Half Banner (234 x 60)', 'verticalBanner' => 'Vertical Banner (120 x 240)', 'skyscraper' => 'Skyscraper (160 x 600)', 'leaderboard' => 'Leaderboard (728 x 92)'); $options = get_option('echocurrent_affiliate_optimizer'); // Init defaults, if necessary if(!is_array($options)) { $options = array( 'website_key' => '', 'zone_style' => '', 'external_border_color' => '#000000', 'internal_border_color' => '#6699FF', 'prod_name_font_color' => null, 'prod_desc_font_color' => '#000000', 'alt_font_color' => '#008800'); } // Form posted? if($_POST['echocurrent_affiliate_submit']) { $ws_key = strip_tags(stripslashes($_POST['ec_website_key'])); $start_pos = strpos($ws_key, '#'); if((string)$start_pos === (string)0) { $ws_key = substr($ws_key, strlen('#')); } $options['website_key'] = $ws_key; $options['zone_style'] = strip_tags(stripslashes($_POST['ec_zone_style'])); $options['external_border_color'] = strip_tags(stripslashes($_POST['ec_external_border_color'])); $options['internal_border_color'] = strip_tags(stripslashes($_POST['ec_internal_border_color'])); $options['background_color'] = strip_tags(stripslashes($_POST['ec_background_color'])); $options['prod_name_font_color'] = strip_tags(stripslashes($_POST['ec_prod_name_font_color'])); $options['prod_desc_font_color'] = strip_tags(stripslashes($_POST['ec_prod_desc_font_color'])); $options['alt_font_color'] = strip_tags(stripslashes($_POST['ec_alt_font_color'])); update_option('echocurrent_affiliate_optimizer', $options); } $website_key_option = htmlspecialchars($options['website_key'], ENT_QUOTES); $zone_style_option = htmlspecialchars($options['zone_style'], ENT_QUOTES); $external_border_color_option = htmlspecialchars($options['external_border_color'], ENT_QUOTES); $internal_border_color_option = htmlspecialchars($options['internal_border_color'], ENT_QUOTES); $background_color_option = htmlspecialchars($options['background_color'], ENT_QUOTES); $prod_name_font_color_option = htmlspecialchars($options['prod_name_font_color'], ENT_QUOTES); $prod_desc_font_color_option = htmlspecialchars($options['prod_desc_font_color'], ENT_QUOTES); $alt_font_color_option = htmlspecialchars($options['alt_font_color'], ENT_QUOTES); echo ' '; // The form fields echo '

'; echo '

'; echo '

'; echo '

'; echo '

'; echo '

'; echo '

'; echo '

'; echo '

Please visit EchoCurrent for ' . ( $website_key_option == null || $website_key_option == '' ? 'registration information' : 'reports') . '.

'; echo ''; } function _generate_zone_style_option($zone_style_option, $current_zone_style, $label) { return ''; } // Widget callback function. Will generate the EchoCurrent Affiliate Products zone, based on options configured by the blog admin function echocurrent_affiliate_zone($args) { extract($args); echo $before_widget; echo $before_title . /* No Title */ '' . $after_title; $options = get_option('echocurrent_affiliate_optimizer'); $website_key = $options['website_key']; if(empty($website_key)) $website_key = '0123456789'; $zone_style = $options['zone_style']; echocurrent_apo_zone('sidebar_widget_ec_apo_zone', $website_key, $zone_style, $options); echo $after_widget; } /* * This is the self-closing shortcode for the EchoCurrent Affiliate Product Optimizer. * Putting this in your post will generate and render a zone, * with the specified attributes. * * Attributes: * zone_id (required) - A unique ID for this zone * echocurrent_id (required) - The ID that you recieved when registering for EchoCurrent APO * zone_style (required) - [rectangleText | mediumRectangleText | verticalRectangleText | fullBanner | halfBanner | verticalBanner | skyscraper | leaderboard] * external_border_color * internal_border_color * background_color * product_name_font_color * product_desc_font_color * alt_font_color * * Usage: * [echocurrent_apo_zone zone_id="testZone" echocurrent_id="0123456789" zone_style="fullBanner"] * [echocurrent_apo_zone zone_id="differentColorZone" echocurrent_id="0123456789" zone_style="leaderboard" external_border_color="yellow" internal_border_color="red"] */ function echocurrent_zone_shortcode($atts) { extract(shortcode_atts(array( 'zone_id' => '', 'echocurrent_id' => '0123456789', 'zone_style' => '', 'external_border_color' => '#000000', 'internal_border_color' => '#6699FF', 'prod_desc_font_color' => '#000000', 'alt_font_color' => '#008800' ), $atts)); if(empty($zone_id) || empty($zone_style)) { return "EchoCurrent Shortcode ($echocurrent_id) - Missing zone_id ($zone_id) or zone_style ($zone_style) attribute(s)"; } else { return echocurrent_generate_zone($zone_id, $echocurrent_id, $zone_style, $atts); } } /* * This is the Template Tag for the EchoCurrent Affiliate Product Optimizer. * Putting this template tag in your template will generate and render a zone, * with the specified arguments. * * Parameters: * zone_id (required) - A unique ID for this zone * echocurrent_id (required) - The ID that you recieved when registering for EchoCurrent APO * zone_style (required) - [rectangleText | mediumRectangleText | verticalRectangleText | fullBanner | halfBanner | verticalBanner | skyscraper | leaderboard] * options - A hash of styling options for the zone. Options include: external_border_color, internal_border_color, background_color, product_name_font_color, product_desc_font_color, alt_font_color * * Usage: * * 'yellow', 'internal_border_color' => 'red')); ?> */ function echocurrent_apo_zone($zone_id, $echocurrent_id, $zone_style, $options = array()) { echo echocurrent_generate_zone($zone_id, $echocurrent_id, $zone_style, $options); } function echocurrent_generate_zone($zone_id, $echocurrent_id, $zone_style, $options = array()) { $ec_server_loc = 'services.echocurrent.com'; // PROD // $ec_server_loc = 'ec-dbrunette:8090/echocurrent-webapp'; // DEV // ensure defaults if(empty($options['external_border_color'])) $options['external_border_color'] = '#000000'; if(empty($options['internal_border_color'])) $options['internal_border_color'] = '#6699FF'; if(empty($options['prod_desc_font_color'])) $options['prod_desc_font_color'] = '#000000'; if(empty($options['alt_font_color'])) $options['alt_font_color'] = '#008800'; $snippet = ""; $snippet .= "
\n"; $snippet .= " \n"; $snippet .= "
\n"; $snippet .= "
\n"; $snippet .= "
\n"; $snippet .= " \n"; $snippet .= "
\n"; $snippet .= " \n"; $snippet .= " \n"; $snippet .= " \n"; $snippet .= "
\n"; $snippet .= "
\n"; $snippet .= "
\n"; return $snippet; } // Private function function _get_width_for_style($zone_style) { switch($zone_style) { case 'rectangleText': return 180; case 'mediumRectangleText': return 300; case 'verticalRectangleText': return 240; case 'fullBanner': return 468; case 'halfBanner': return 234; case 'verticalBanner': return 120; case 'skyscraper': return 160; case 'leaderboard': return 728; } } // Private function function _get_height_for_style($zone_style) { switch($zone_style) { case 'rectangleText': return 150; case 'mediumRectangleText': return 250; case 'verticalRectangleText': return 400; case 'fullBanner': return 60; case 'halfBanner': return 60; case 'verticalBanner': return 240; case 'skyscraper': return 600; case 'leaderboard': return 92; } } // Private function function _get_signoff_for_style($zone_style) { switch($zone_style) { case 'rectangleText': case 'fullBanner': case 'halfBanner': case 'verticalBanner': return 'by'; case 'mediumRectangleText': case 'verticalRectangleText': return 'Products recommended by'; case 'skyscraper': case 'leaderboard': return 'Recommended by'; } } function init_echocurrent() { register_sidebar_widget('EchoCurrent Affiliate Product Optimizer', 'echocurrent_affiliate_zone'); register_widget_control(array('EchoCurrent Affiliate Product Optimizer', 'widgets'), 'echocurrent_affiliate_control', 300, 200); add_shortcode('echocurrent_apo_zone', 'echocurrent_zone_shortcode'); } add_action('plugins_loaded', 'init_echocurrent'); ?>