Plugin Directory

Changeset 881512


Ignore:
Timestamp:
03/25/2014 07:28:50 AM (12 years ago)
Author:
aniketpant
Message:

Start afresh for new version

Location:
instamojo/branches/develop
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • instamojo/branches/develop/index.php

    r879910 r881512  
    11<?php
    2 /*
    3     Plugin Name: Instamojo button
    4     Plugin URI: http://www.instamojo.com
    5     Description: Embed your Instamojo items directly into your WordPress site.
    6     Version: 0.1.0
    7     Author: Instamojo
    8     Author URI: http://www.instamojo.com
    9 */
    10     if(!defined('ABSPATH'))
    11         exit;
    122
    13     define('INSTAMOJO_VERSION', '0.1.0');
    14     define('INSTAMOJO_DIR', plugin_dir_path(__FILE__));
    15     define('INSTAMOJO_URL', plugin_dir_url(__FILE__));
    16     define('INSTAMOJO_NAME', 'INSTAMOJO');
     3/**
     4 * Plugin Name: Instamojo button
     5 * Plugin URI: http://www.instamojo.com
     6 * Description: Embed your Instamojo items directly into your WordPress site.
     7 * Version: 0.1.0
     8 * Author: Instamojo
     9 * Author URI: http://www.instamojo.com
     10 */
    1711
    18     //register the widget and the shortcode.
    19     register_activation_hook(__FILE__, 'instamojo_activation_hook');
    20     add_action('plugins_loaded', 'instamojo_plugin_loaded');
     12if(!defined('ABSPATH'))
     13  exit;
    2114
    22     function instamojo_activation_hook() {
    23         add_option('instamojo_version', INSTAMOJO_VERSION);
    24     }
     15define('INSTAMOJO_VERSION', '0.1.0');
     16define('INSTAMOJO_DIR', plugin_dir_path(__FILE__));
     17define('INSTAMOJO_URL', plugin_dir_url(__FILE__));
     18define('INSTAMOJO_NAME', 'INSTAMOJO');
    2519
    26     function instamojo_plugin_loaded() {
    27         require_once( INSTAMOJO_DIR.'shortcode.php' );
    28         new instamojo_shortcode();
    29         add_action('widgets_init', 'instamojo_widgets_init');
    30     }
     20//register the widget and the shortcode.
     21register_activation_hook(__FILE__, 'instamojo_activation_hook');
     22add_action('plugins_loaded', 'instamojo_plugin_loaded');
    3123
    32     function instamojo_widgets_init() {
    33         require_once(INSTAMOJO_DIR.'widget.php');
    34         register_widget('instamojo_widget');
    35     }
     24function instamojo_activation_hook() {
     25  add_option('instamojo_version', INSTAMOJO_VERSION);
     26}
     27
     28function instamojo_plugin_loaded() {
     29  require_once( INSTAMOJO_DIR.'shortcode.php' );
     30  new instamojo_shortcode();
     31  add_action('widgets_init', 'instamojo_widgets_init');
     32}
     33
     34function instamojo_widgets_init() {
     35  require_once(INSTAMOJO_DIR.'widget.php');
     36  register_widget('instamojo_widget');
     37}
     38
    3639?>
  • instamojo/branches/develop/shortcode.php

    r879873 r881512  
    22
    33/**
    4 * Instamojo Shortcode
    5 * Use this shortcode in your wordpress post to show your instamojo offer.
    6 * Example - [instamojo instamojo_url="URL" type="large" button_pos="top"
    7 *            topic_color="#000000" button_color="#000000" bg_color="#000000"
    8 *            bg_color="#000000" description_color="#000000" price_color="#000000"
    9 *           ][/instamojo]
    10 */
    11 
    12 
    13 class instamojo_shortcode {
    14 
    15     /**
    16     * Default constructor.
    17     */
    18     function __construct() {
    19         //register the function add_short
    20         add_shortcode( 'instamojo', array( &$this, 'add_short' ) );
    21     }
    22 
    23     /**
    24     *   This is called by wordpress when the constructor is initialized.
    25     *   @param $atts array Attributs of the shortcode.
    26     *   @param $content array Content between the starting and ending shortcode tags.
    27     */
    28     function add_short($atts, $content) {
    29         $currency_html_map = array();
    30         $currency_html_map["INR"] = "&#8377;";
    31         $currency_html_map["USD"] = "&#36;";
    32         $atts = shortcode_atts( array(
    33                 'instamojo_url' => '',
    34                 'type' => 'small',
    35                 'button_pos' => 'bottom',
    36                 'topic_color' => '#000000',
    37                 'button_color' => '#b8e0ff',
    38                 'bg_color' => '#1ff4be',
    39                 'description_color' => '#000000',
    40                 'price_color' => '#000000',
    41             ), $atts);
    42         $atts['instamojo_url'] = substr($atts['instamojo_url'], 0, -1);
    43         $add_feed = (substr($atts['instamojo_url'], -1) == '/') ? "feed.json" : "/feed.json";
    44         $offer_array = json_decode(file_get_contents($atts['instamojo_url'].$add_feed));
    45         $offer_data = array();
    46         $offer_data["title"] = $offer_array->{'offer'}->{'title'};
    47         $offer_data["description"] = $offer_array->{'offer'}->{'description'};
    48         $offer_data["base_price"] = $offer_array->{'offer'}->{'base_price'};
    49         $offer_data["url"] = $atts['instamojo_url'];
    50         $offer_data["cover_image"] = $offer_array->{'offer'}->{'cover_image'};
    51         $offer_data["button_pos"] = $atts["button_pos"];
    52         $offer_data["topic_color"] = $atts["topic_color"];
    53         $offer_data["description_color"] = $atts["description_color"];
    54         $offer_data["button_color"] = $atts["button_color"];
    55         $offer_data["bg_color"] = $atts["bg_color"];
    56         $offer_data["price_color"] = $atts["price_color"];
    57         $offer_currency_html = $currency_html_map[$offer_array->{'offer'}->{'currency'}];
    58         $response = get_headers($atts['instamojo_url']);
    59         $responce_code = substr($response[0], 9, 3);
    60         if(substr($atts['instamojo_url'], -1) == '/')
    61             $atts['instamojo_url'] = substr($atts['instamojo_url'], 0, -1);
    62         if ((strpos($atts['instamojo_url'], 'www.instamojo.com') === false && $responce_code != "404") || $responce_code == "404") {
    63             $offer_data['title'] = "404 error";
    64             $offer_data['url'] = "#";
    65             $offer_data['description'] = "";
    66             $offer_data['cover_image'] = "";
    67         }
    68         if($atts['type'] == 'small') return $this->small_html($offer_currency_html, $offer_data);
    69         return $this->large_html($offer_currency_html, $offer_data);
    70     }
    71 
    72     /**
    73     *   Utility function for the small widget.
    74     *   @param $currency_html string HTML value of the currency.
    75     *   @param $data array consisting the data of the offer.
    76     */
    77     function small_html($currency_html, $data) {
    78         $button_html = "<div><form action='".$data['url']."' target='_blank'><input id='short-mojo-link' type='submit' value='BUY'></form></div>";
    79         $html = "";
    80         $html .= "<div id='short-small-div'>";
    81             if($data["button_pos"]=="top") $html .= $button_html;
    82             $html .= "<div id='short-offer-title'>";
    83                 $html .= "<h4>".$data['title']."</h4>";
    84             $html .= "</div>";
    85             $html .= "<div id='short-currency-price'>";
    86                 $html .= "<h4>".$currency_html." ".$data['base_price']."</h4>";
    87             $html .= "</div>";
    88             if($data["button_pos"]=="bottom") $html .= $button_html;
    89         $html .= '</div>';
    90         $html .= "<script>document.getElementById('short-offer-title').style.color = ".'"'.$data['topic_color'].'";';
    91         $html .= "document.getElementById('short-mojo-link').style.background = ".'"'.$data['button_color'].'";';
    92         $html .= "document.getElementById('short-small-div').style.background = ".'"'.$data['bg_color'].'";';
    93         $html .= "document.getElementById('short-small-div').style.borderRadius = ".'"10px";';
    94         $html .= "document.getElementById('short-small-div').style.padding = ".'"4px";';
    95         $html .= "document.getElementById('short-small-div').style.width = ".'"180px";';
    96         $html .= "document.getElementById('short-small-div').style.textAlign = ".'"center";</script>';
    97         return $html;
    98     }
    99 
    100     /**
    101     *   Utility function for the large widget.
    102     *   @param $currency_html string HTML value of the currency.
    103     *   @param $data array consisting the data of the offer.
    104     */
    105     function large_html($currency_html, $data) {
    106         $button_html = "<div><form action='".$data['url']."' target='_blank'><input id='short-mojo-link' type='submit' value='BUY'></form></div>";
    107         $html = "";
    108         $html .= "<div id='short-large-div'>";
    109             if($data["button_pos"]=="top") $html .= $button_html;
    110             $html .= "<div id='short-large-offer-title'>";
    111                 $html .= "<h5>".$data['title']."</h5>";
    112             $html .= "</div>";
    113             $html .= "<div id='short-cover-image'>";
    114                 $html .= "<img src=".$data["cover_image"]."></img>";
    115             $html .= "</div>";
    116             $html .= "<div id='short-description'>";
    117                 $html .= "<h6>".$data['description']."</h6>";
    118             $html .= "</div>";
    119             $html .= "<div id='short-currency-price'>";
    120                 $html .= "<h5>".$currency_html." ".$data['base_price']."</h5>";
    121             $html .= "</div>";
    122             if($data["button_pos"]=="bottom") $html .= $button_html;
    123         $html .= '</div>';
    124         $html .= "<script>document.getElementById('short-large-offer-title').style.color = ".'"'.$data['topic_color'].'";';
    125         $html .= "document.getElementById('short-description').style.color = ".'"'.$data['description_color'].'";';
    126         $html .= "document.getElementById('short-mojo-link').style.background = ".'"'.$data['button_color'].'";';
    127         $html .= "document.getElementById('short-large-div').style.background = ".'"'.$data['bg_color'].'";';
    128         $html .= "document.getElementById('short-large-div').style.borderRadius = ".'"10px";';
    129         $html .= "document.getElementById('short-large-div').style.padding = ".'"4px";';
    130         $html .= "document.getElementById('short-large-div').style.textAlign = ".'"center";</script>';
    131         return $html;
    132     }
    133 }
     4 * Shortcodes
     5 */
    1346
    1357?>
  • instamojo/branches/develop/widget.php

    r879873 r881512  
    22
    33/**
    4 * Instamojo Widget.
    5 * It extends the WordPress Widget class.
    6 */
    7 class instamojo_widget extends WP_Widget{
     4 * Instamojo Widget.
     5 * It extends the WordPress Widget class.
     6 */
     7class instamojo_widget extends WP_Widget {
    88
    99
    10     /**
    11     *   Default constructor.
    12     */
    13     function instamojo_widget() {
    14         // Load any other optional scripts
    15         add_action('load-widgets.php', array(&$this, 'my_custom_load'));
     10  /**
     11   *  Default constructor.
     12   */
     13  function instamojo_widget() {
     14    // Load any other optional scripts
     15    add_action('load-widgets.php', array(&$this, 'my_custom_load'));
    1616
    17         // Name and class of widget.
    18         $widget_options = array(
    19             'classname' => 'instamojo-widget',
    20             'description' => 'Display Instamojo offers in your blog.');
     17    // Name and class of widget.
     18    $widget_options = array(
     19      'classname' => 'instamojo-widget',
     20      'description' => 'Display Instamojo offers in your blog.');
    2121
    22         // Id, width and height of the widget.
    23         $control_options = array(
    24             'id_base' => 'instamojo-widget',
    25             'width' => 300,
    26             'height' => 200);
     22    // Id, width and height of the widget.
     23    $control_options = array(
     24      'id_base' => 'instamojo-widget',
     25      'width' => 300,
     26      'height' => 200);
    2727
    28         // Initialize the widget.
    29         $this->WP_Widget('instamojo-widget', 'instamojo',  $widget_options, $control_options);
    30     }
     28    // Initialize the widget.
     29    $this->WP_Widget('instamojo-widget', 'instamojo',  $widget_options, $control_options);
     30  }
    3131
    32     /**
    33     *   Called in the constructor.
    34     */
    35     function my_custom_load() {
     32  /**
     33   *  Called in the constructor.
     34   */
     35  function my_custom_load() {
    3636
    3737  }
    3838
    39     /**
    40     *   Implements the widget() function as required by WordPress.
    41     *   This is responsible for how the widget looks in your WordPress site.
    42     */
    43     function widget($args, $instance) {
    44         wp_register_style('widgetcss', plugin_dir_url(__FILE__).'assets/css/imojo.css');
    45         wp_enqueue_style('widgetcss');
     39  /**
     40   *  Implements the widget() function as required by WordPress.
     41   *  This is responsible for how the widget looks in your WordPress site.
     42   */
     43  function widget($args, $instance) {
     44    wp_register_style('widgetcss', plugin_dir_url(__FILE__).'assets/css/imojo.css');
     45    wp_enqueue_style('widgetcss');
    4646
    47         // Holds a mapping for currency to HTML of that currency.
    48         $currency_html_map = array();
    49         $currency_html_map["INR"] = "&#8377;";
    50         $currency_html_map["USD"] = "&#36;";
     47    // Holds a mapping for currency to HTML of that currency.
     48    $currency_html_map = array();
     49    $currency_html_map["INR"] = "&#8377;";
     50    $currency_html_map["USD"] = "&#36;";
    5151
    52         extract($args);
    53         $title = apply_filters('widget_title', $instance['title']);
    54         echo $before_widget;
    55         $add_feed = (substr($instance['instamojo_url'], -1) == '/') ? "feed.json" : "/feed.json";
     52    extract($args);
     53    $title = apply_filters('widget_title', $instance['title']);
     54    echo $before_widget;
     55    $add_feed = (substr($instance['instamojo_url'], -1) == '/') ? "feed.json" : "/feed.json";
    5656
    57         // Getting details from the link given in instamojo_url.
    58         $offer_array = json_decode(file_get_contents($instance['instamojo_url'].$add_feed));
     57    // Getting details from the link given in instamojo_url.
     58    $offer_array = json_decode(file_get_contents($instance['instamojo_url'].$add_feed));
    5959
    60         $offer_title = $offer_array->{'offer'}->{'title'};
    61         $offer_description = $offer_array->{'offer'}->{'description'};
    62         $offer_base_price = $offer_array->{'offer'}->{'base_price'};
    63         $offer_currency = $offer_array->{'offer'}->{'currency'};
    64         $offer_image = $offer_array->{'offer'}->{'cover_image'};
     60    $offer_title = $offer_array->{'offer'}->{'title'};
     61    $offer_description = $offer_array->{'offer'}->{'description'};
     62    $offer_base_price = $offer_array->{'offer'}->{'base_price'};
     63    $offer_currency = $offer_array->{'offer'}->{'currency'};
     64    $offer_image = $offer_array->{'offer'}->{'cover_image'};
    6565
    66         // If title is not given make it My Instamojo Product.
    67         if ($instance['title']) {
    68             echo $before_title.$instance['title'].$after_title;
    69         }
    70         else {
    71             echo $before_title.'My Instamojo Product'.$after_title;
    72         }
     66    // If title is not given make it My Instamojo Product.
     67    if ($instance['title']) {
     68      echo $before_title.$instance['title'].$after_title;
     69    }
     70    else {
     71      echo $before_title.'My Instamojo Product'.$after_title;
     72    }
    7373
    74         $button_html = '<div class="btn-container"><a href="'.$instance['instamojo_url'].'" ';
    75         if ($instance['button_style'] != 'none') {
    76             $button_html .= 'class="im-checkout-btn btn--'.$instance['button_style'].'" ';
    77         }
    78         $button_html .= 'target="_blank">Buy Now</a></div>';
    79         ?>
    80         <div id="wid-small-div">
    81         <?php if ($instance['button_pos'] == 'top') echo $button_html; ?>
    82             <div id="wid-offer-title">
    83             <?php   if ($instance['title'] == '404 error') echo '<h4>Error in offer URL!</h4>'; else echo '<h4>'.$offer_title.'</h4>'; ?>
    84             </div>
    85             <div id="wid-currency-price">
    86                 <h4><?php echo $currency_html_map[$offer_currency].' '.$offer_base_price; ?></h4>
    87             </div>
    88             <?php if ($instance['button_pos'] == 'bottom') echo $button_html;   ?>
    89         </div>
    90         <?php
    91         echo $after_widget;
    92     }
     74    $button_html = '<div class="btn-container"><a href="'.$instance['instamojo_url'].'" ';
     75    if ($instance['button_style'] != 'none') {
     76      $button_html .= 'class="im-checkout-btn btn--'.$instance['button_style'].'" ';
     77    }
     78    $button_html .= 'target="_blank">Buy Now</a></div>';
     79    ?>
     80    <div id="wid-small-div">
     81      <?php if ($instance['button_pos'] == 'top') echo $button_html; ?>
     82      <div id="wid-offer-title">
     83        <?php if ($instance['title'] == '404 error') echo '<h4>Error in offer URL!</h4>'; else echo '<h4>'.$offer_title.'</h4>'; ?>
     84      </div>
     85      <div id="wid-currency-price">
     86        <h4><?php echo $currency_html_map[$offer_currency].' '.$offer_base_price; ?></h4>
     87      </div>
     88      <?php if ($instance['button_pos'] == 'bottom') echo $button_html; ?>
     89    </div>
     90    <?php
     91    echo $after_widget;
     92  }
    9393
    94     /**
    95     *   Implements the update() function as required by WordPress.
    96     *   This works when you fill data in the widget form input from the WordPress admin.
    97     */
    98     function update($new_instance, $old_instance) {
    99         $instance = $old_instance;
    100         $instance['button_pos'] = strip_tags($new_instance['button_pos']);
    101         $instance['instamojo_url'] = strip_tags($new_instance['instamojo_url']);
    102         $ch = curl_init($instance['instamojo_url']);
    103         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    104         curl_exec($ch);
    105         $instance['instamojo_url'] = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
    106         curl_close($ch);
    107         if(substr($instance['instamojo_url'], -1) == '/')
    108             $instance['instamojo_url'] = substr($instance['instamojo_url'], 0, -1);
    109         if($instance['instamojo_url'][0] == 'h' && $instance['instamojo_url'][5] == 's')
    110             $instance['instamojo_url'] = substr($instance['instamojo_url'], 9);
    111         if($instance['instamojo_url'][0] == 'h')
    112             $instance['instamojo_url'] = substr($instance['instamojo_url'], 8);
    113         $instance['title'] = strip_tags($new_instance['title']);
    114         $instance['button_style'] = strip_tags($new_instance['button_style']);
    115         $response = get_headers($instance['instamojo_url']);
    116         $responce_code = substr($response[0], 9, 3);
    117         $url_pieces = explode("/", $instance['instamojo_url']);
    118         if ((strpos($instance['instamojo_url'], 'www.instamojo.com') === false && $responce_code != "404") || $responce_code == "404" || count($url_pieces) != 3) {
    119             $instance['title'] = "404 error";
    120             $instance['instamojo_url'] = "#";
    121         }
    122         $instance['instamojo_url'] = 'https://'.$instance['instamojo_url'];
    123         return $instance;
    124     }
     94  /**
     95   *  Implements the update() function as required by WordPress.
     96   *  This works when you fill data in the widget form input from the WordPress admin.
     97   */
     98  function update($new_instance, $old_instance) {
     99    $instance = $old_instance;
     100    $instance['button_pos'] = strip_tags($new_instance['button_pos']);
     101    $instance['instamojo_url'] = strip_tags($new_instance['instamojo_url']);
     102    $ch = curl_init($instance['instamojo_url']);
     103    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     104    curl_exec($ch);
     105    $instance['instamojo_url'] = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
     106    curl_close($ch);
     107    if(substr($instance['instamojo_url'], -1) == '/')
     108      $instance['instamojo_url'] = substr($instance['instamojo_url'], 0, -1);
     109    if($instance['instamojo_url'][0] == 'h' && $instance['instamojo_url'][5] == 's')
     110      $instance['instamojo_url'] = substr($instance['instamojo_url'], 9);
     111    if($instance['instamojo_url'][0] == 'h')
     112      $instance['instamojo_url'] = substr($instance['instamojo_url'], 8);
     113    $instance['title'] = strip_tags($new_instance['title']);
     114    $instance['button_style'] = strip_tags($new_instance['button_style']);
     115    $response = get_headers($instance['instamojo_url']);
     116    $responce_code = substr($response[0], 9, 3);
     117    $url_pieces = explode("/", $instance['instamojo_url']);
     118    if ((strpos($instance['instamojo_url'], 'www.instamojo.com') === false && $responce_code != "404") || $responce_code == "404" || count($url_pieces) != 3) {
     119      $instance['title'] = "404 error";
     120      $instance['instamojo_url'] = "#";
     121    }
     122    $instance['instamojo_url'] = 'https://'.$instance['instamojo_url'];
     123    return $instance;
     124  }
    125125
    126     /**
    127     *   Implements the form() function as required by WordPress.
    128     *   This is responsible for how the form in the wordpess admin looks.
    129     */
    130     function form($instance) {
    131         $defaults = array('title' => '', 'instamojo_url' => '', 'button_pos' => 'top', 'button_style' => 'none', 'type' => true);
    132         $instance = wp_parse_args((array)$instance, $defaults);
    133         ?>
    134         <p>
    135             <label for="<?php echo $this->get_field_id('title');?>">Widget Title:</label>
    136             <input id="<?php echo $this->get_field_id('title');?>"
    137                 name="<?php echo $this->get_field_name('title');?>"
    138                 value="<?php echo $instance['title'];?>"
    139             style="width:100%"/>
    140         </p>
    141         <p>
    142             <label for="<?php echo $this->get_field_id('instamojo_url');?>">Instamojo Offer URL:</label>
    143             <input id="<?php echo $this->get_field_id('instamojo_url');?>"
    144                 name="<?php echo $this->get_field_name('instamojo_url');?>"
    145                 value="<?php echo $instance['instamojo_url'];?>"
    146             style="width:100%"/>
    147         </p>
    148         <p>
    149             <label for="<?php echo $this->get_field_id('button_pos'); ?>"><?php _e('Button Position:'); ?></label>
    150             <select id="<?php echo $this->get_field_id('button_pos'); ?>" name="<?php echo $this->get_field_name('button_pos'); ?>">
    151                 <option value="top" <?php if($instance['button_pos'] == 'top') echo 'selected="selected"'; ?>>Top</option>
    152                 <option value="bottom" <?php if($instance['button_pos'] == 'bottom') echo 'selected="selected"'; ?>>Bottom</option>
    153             </select>
    154         </p>
    155         <p>
    156             <label for="<?php echo $this->get_field_id('button_style'); ?>">Button Style</label>
    157             <select id="<?php echo $this->get_field_id('button_style'); ?>" name="<?php echo $this->get_field_name('button_style'); ?>">
    158                 <option value="light" <?php if($instance['button_style'] == 'light') echo 'selected="selected"'; ?>>Light</option>
    159                 <option value="dark" <?php if($instance['button_style'] == 'dark') echo 'selected="selected"'; ?>>Dark</option>
    160                 <option value="flat" <?php if($instance['button_style'] == 'flat') echo 'selected="selected"'; ?>>Flat Light</option>
    161                 <option value="flat-dark" <?php if($instance['button_style'] == 'flat-dark') echo 'selected="selected"'; ?>>Flat Dark</option>
    162                 <option value="none" <?php if($instance['button_style'] == 'none') echo 'selected="selected"'; ?>>None</option>
    163             </select>
    164         </p>
    165         <?php
    166     }
     126  /**
     127   *  Implements the form() function as required by WordPress.
     128   *  This is responsible for how the form in the WordPress admin looks.
     129   */
     130  function form($instance) {
     131    $defaults = array('title' => '', 'instamojo_url' => '', 'button_pos' => 'top', 'button_style' => 'none', 'type' => true);
     132    $instance = wp_parse_args((array)$instance, $defaults);
     133    ?>
     134    <p>
     135      <label for="<?php echo $this->get_field_id('title');?>">Widget Title:</label>
     136      <input id="<?php echo $this->get_field_id('title');?>"
     137        name="<?php echo $this->get_field_name('title');?>"
     138        value="<?php echo $instance['title'];?>"
     139      style="width:100%"/>
     140    </p>
     141    <p>
     142      <label for="<?php echo $this->get_field_id('instamojo_url');?>">Instamojo Offer URL:</label>
     143      <input id="<?php echo $this->get_field_id('instamojo_url');?>"
     144        name="<?php echo $this->get_field_name('instamojo_url');?>"
     145        value="<?php echo $instance['instamojo_url'];?>"
     146      style="width:100%"/>
     147    </p>
     148    <p>
     149      <label for="<?php echo $this->get_field_id('button_pos'); ?>"><?php _e('Button Position:'); ?></label>
     150      <select id="<?php echo $this->get_field_id('button_pos'); ?>" name="<?php echo $this->get_field_name('button_pos'); ?>">
     151        <option value="top" <?php if($instance['button_pos'] == 'top') echo 'selected="selected"'; ?>>Top</option>
     152        <option value="bottom" <?php if($instance['button_pos'] == 'bottom') echo 'selected="selected"'; ?>>Bottom</option>
     153      </select>
     154    </p>
     155    <p>
     156      <label for="<?php echo $this->get_field_id('button_style'); ?>">Button Style</label>
     157      <select id="<?php echo $this->get_field_id('button_style'); ?>" name="<?php echo $this->get_field_name('button_style'); ?>">
     158        <option value="light" <?php if($instance['button_style'] == 'light') echo 'selected="selected"'; ?>>Light</option>
     159        <option value="dark" <?php if($instance['button_style'] == 'dark') echo 'selected="selected"'; ?>>Dark</option>
     160        <option value="flat" <?php if($instance['button_style'] == 'flat') echo 'selected="selected"'; ?>>Flat Light</option>
     161        <option value="flat-dark" <?php if($instance['button_style'] == 'flat-dark') echo 'selected="selected"'; ?>>Flat Dark</option>
     162        <option value="none" <?php if($instance['button_style'] == 'none') echo 'selected="selected"'; ?>>None</option>
     163      </select>
     164    </p>
     165    <?php
     166  }
    167167}
    168168?>
Note: See TracChangeset for help on using the changeset viewer.