mailin
Last commit date
css
13 years ago
js
13 years ago
lang
13 years ago
api_form.php
13 years ago
compatibility.php
13 years ago
cron.php
13 years ago
listings.php
13 years ago
mailin.php
13 years ago
mailin_widget.php
13 years ago
mailinapi.class.php
13 years ago
readme.txt
13 years ago
mailin_widget.php
101 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | Plugin Name: Foo Widget |
| 5 | Plugin URI: http://jamesbruce.me/ |
| 6 | Description: Random Post Widget grabs a random post and the associated thumbnail to display on your sidebar |
| 7 | Author: sachin |
| 8 | Version: 1 |
| 9 | Author URI: http://jamesbruce.me/ |
| 10 | */ |
| 11 | |
| 12 | |
| 13 | /** |
| 14 | * Adds Foo_Widget widget. |
| 15 | */ |
| 16 | |
| 17 | function getMailinSubscriptionForm(){ |
| 18 | |
| 19 | if(get_option('mailin_list_selected') != '') { |
| 20 | ?> |
| 21 | <div id="mailin_signup_box"> |
| 22 | <form id="mailin_signup_form" action="#mailin_signup_box" method="post"> |
| 23 | <input type="hidden" value="subscribe_form_submit" name="mailin_form_action"> |
| 24 | <div class="mailin_signup_box_inside"> |
| 25 | |
| 26 | <div class="mailin_signup_box_row"> |
| 27 | <span class="mailin_widget_head"><?php esc_html_e('Subscribe to newsletter', 'mailin_i18n'); ?></span> |
| 28 | </div> |
| 29 | |
| 30 | <?php if(mailin_messages() != ''){ ?> |
| 31 | <div id="mailin_message" > |
| 32 | <?php echo mailin_messages(); ?> |
| 33 | </div> |
| 34 | <?php } ?> |
| 35 | |
| 36 | <div class="mailin_signup_box_row"> |
| 37 | <label ><?php echo esc_html_e('First name' , 'mailin_i18n')?><span class="required">*</span></label> |
| 38 | <input type="text" id="fname" name="fname" value="<?php echo isset($_POST['fname']) ? $_POST['fname'] : '' ?>" size="21" maxlength="55"> |
| 39 | </div> |
| 40 | |
| 41 | <div class="mailin_signup_box_row"> |
| 42 | <label ><?php echo esc_html_e('Last name' , 'mailin_i18n')?><span class="required">*</span></label> |
| 43 | <input type="text" id="lname" name="lname" value="<?php echo isset($_POST['lname']) ? $_POST['lname'] : '' ?>" size="21" maxlength="55"> |
| 44 | </div> |
| 45 | |
| 46 | <div class="mailin_signup_box_row"> |
| 47 | <label ><?php echo esc_html_e('Email' , 'mailin_i18n')?><span class="required">*</span></label> |
| 48 | <input type="text" id="mailin_email" name="mailin_email" value="<?php echo isset($_POST['mailin_email']) ? $_POST['mailin_email'] : '' ?>" size="21"> |
| 49 | </div> |
| 50 | |
| 51 | <div class="mailin_signup_box_row right"> |
| 52 | <input type="submit" class="button" value="<?php echo esc_html_e('Subscribe' , 'mailin_i18n')?>" id="mailin_signup_submit" name="mailin_signup_submit"> |
| 53 | </div> |
| 54 | </div> |
| 55 | </form> |
| 56 | </div> |
| 57 | <?php |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | |
| 62 | class Mailin_Widget extends WP_Widget { |
| 63 | |
| 64 | /** |
| 65 | * Register widget with WordPress. |
| 66 | */ |
| 67 | public function __construct() { |
| 68 | parent::__construct( |
| 69 | 'mailin_widget', // Base ID |
| 70 | 'Mailin_Widget', // Name |
| 71 | array('description' => __( 'Mailin Widget', 'mailin_i18n' ), ) // Args |
| 72 | ); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Front-end display of widget. |
| 77 | * |
| 78 | * @see WP_Widget::widget() |
| 79 | * |
| 80 | * @param array $args Widget arguments. |
| 81 | * @param array $instance Saved values from database. |
| 82 | */ |
| 83 | public function widget( $args, $instance ) { |
| 84 | |
| 85 | extract( $args ); |
| 86 | |
| 87 | if (!is_array($instance)) { |
| 88 | $instance = array(); |
| 89 | } |
| 90 | getMailinSubscriptionForm(array_merge($args, $instance)); |
| 91 | } |
| 92 | |
| 93 | |
| 94 | } // class Foo_Widget |
| 95 | |
| 96 | // register Foo_Widget widget |
| 97 | |
| 98 | add_action( 'widgets_init', create_function( '', 'register_widget( "Mailin_Widget" );' )); |
| 99 | |
| 100 | ?> |
| 101 |