Amazon UK WordPress Plugin Source Code

Similar to the AMazon.com version, this was for the UK site but they dropped the ad support

<?php
/*
Plugin Name: amazon uk contextual ads
Plugin URI:
Description: This plugin adds the amazon contextual ads code to your blog
Version: 0.1
Author: IH
Author URI: http://www.getphp.net
*/

// This function outputs the amazon javascript for the configured user
function amazonuk_output()
{
    // get the publisher id
    $amazonuk_id = get_option(‘amazonuk_id’);
    ?>
 <!– start of amazon uk context links code –>
<script type=”text/javascript”><!–
 amzn_cl_tag=”<?php echo $amazonuk_id ?>”;
 amzn_cl_link_color=”0000FF”;
 amzn_cl_max_links=12;
 amzn_cl_link_style=3;
//–></script>
<script type=”text/javascript” src=”http://cls.assoc-amazon.co.uk/gb/s/cls.js”></script>
    <!– end of amazon uk context links code –>
<?php
}

// Adds the amazon settings menu to the WordPress options page
function amazonuk_menu()
{
    add_options_page(‘Amazon UK Settings’, ‘Amazon UK Settings’, 8, __FILE__, ‘amazonuk_options’);
}

// Output the options menu page
function amazonuk_options()
{
    ?>
    <div class=”wrap”>
    <h2>Amazon UK Settings </h2>

 <form method=”post” action=””>
 <?php wp_nonce_field(‘update-options’); ?>
 <p class=”submit”>
 <input type=”submit” name=”Submit” value=”<?php _e(‘Update Options »’) ?>” />
 </p>

 <?php
     echo ‘<table>’;
     $parameters = array
  (
     ‘amazonuk_id’ => ‘Amazon UK publisher ID’,
     );

     if ($_POST[‘action’] == ‘update’)
  {
  foreach($parameters as $param => $desc)
  {
      update_option($param, $_POST[$param]);
  }
     }
    
     foreach($parameters as $param => $desc){
  echo “<tr><td> $desc: </td> <td> <input type=’text’ name=’$param’ value='”.get_option($param).”‘ /> </td></tr>”;
     }
     echo ‘</table>’;
     $page_options = implode(‘,’, array_keys($parameters));
 ?>
 
 <input type=”hidden” name=”page_options” value=”<?php echo $page_options ?>” />
 <input type=”hidden” name=”action” value=”update” />

 <p class=”submit”>
 <input type=”submit” name=”Submit” value=”<?php _e(‘Update Options »’) ?>” />
 </p>
 </form>
    </div>
    <?php
}

add_option(‘amazonuk_id’, ‘xxxxxxxxxxxx’);
add_action(‘admin_menu’, ‘amazonuk_menu’);
add_action(‘wp_footer’, ‘amazonuk_output’);
?>

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*