mailin
Last commit date
css
12 years ago
emails
12 years ago
img
12 years ago
js
12 years ago
lang
12 years ago
ajaxcall.php
12 years ago
ajaxcontent.php
12 years ago
ajaxmanagesubscribe.php
12 years ago
ajaxsmtp.php
12 years ago
api_form.php
12 years ago
compatibility.php
12 years ago
cron.php
12 years ago
listings.php
12 years ago
mailin.php
12 years ago
mailin_widget.php
12 years ago
mailinapi.class.php
12 years ago
readme.html
12 years ago
mailin_widget.php
196 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | Description: This is mailin widget which is working with mailin wordpress plugin . from this widget you can manage title of the block displayed in front office . you can also manage to display Prenom and Nom. |
| 5 | Author: deshbandhu |
| 6 | Version: 1 |
| 7 | Author URI: http://mailin.fr/ |
| 8 | */ |
| 9 | |
| 10 | |
| 11 | /** |
| 12 | * Adds Foo_Widget widget. |
| 13 | */ |
| 14 | |
| 15 | function getMailinSubscriptionForm($arg) |
| 16 | { |
| 17 | |
| 18 | $api_key = get_option('mailin_apikey'); |
| 19 | |
| 20 | $mailin_apikey_status = get_option('mailin_apikey_status'); |
| 21 | |
| 22 | $mailin_manage_subscribe = get_option('mailin_manage_subscribe'); |
| 23 | |
| 24 | $mailin_unsubscribe = get_option('mailin_unsubscribe'); |
| 25 | |
| 26 | if ($api_key == false || $mailin_apikey_status == 0 || $mailin_manage_subscribe == 0) |
| 27 | return false; |
| 28 | if (get_option('mailin_list_selected') != '') |
| 29 | { |
| 30 | ?> |
| 31 | <div id="mailin_signup_box"> |
| 32 | <form id="mailin_signup_form" action="#mailin_signup_box" method="post"> |
| 33 | <input type="hidden" value="subscribe_form_submit" name="mailin_form_action"> |
| 34 | <div class="mailin_signup_box_inside"> |
| 35 | <div class="mailin_signup_box_row"> |
| 36 | <span class="mailin_widget_head"> <?php esc_html_e($arg['title'], 'mailin_i18n');?></span></div> |
| 37 | <?php |
| 38 | if (mailinMessages() != '') |
| 39 | { |
| 40 | ?> |
| 41 | <div id="mailin_message"> |
| 42 | <?php |
| 43 | echo mailinMessages(); |
| 44 | ?> |
| 45 | </div> |
| 46 | <?php |
| 47 | } |
| 48 | ?> |
| 49 | |
| 50 | <?php |
| 51 | if ($arg['firstname'] == 1) |
| 52 | { |
| 53 | ?> |
| 54 | <div class="mailin_signup_box_row"> |
| 55 | <label><?php echo esc_html_e('First name', 'mailin_i18n'); ?><span class="required">*</span></label> |
| 56 | <input type="text" id="fname" name="fname" value="<?php echo isset($_POST['fname']) ? $_POST['fname'] : ''; ?>" size="21" maxlength="55"> |
| 57 | </div> |
| 58 | <?php |
| 59 | } |
| 60 | ?> |
| 61 | |
| 62 | <?php |
| 63 | if ($arg['lastname'] == 2) |
| 64 | { |
| 65 | ?> |
| 66 | <div class="mailin_signup_box_row"> |
| 67 | <label><?php echo esc_html_e('Last name', 'mailin_i18n');?><span class="required">*</span> |
| 68 | </label><input type="text" id="lname" name="lname" value="<?php echo isset($_POST['lname']) ? $_POST['lname'] : ''; ?>" size="21" maxlength="55"> |
| 69 | </div> |
| 70 | <?php }?> |
| 71 | |
| 72 | <div class="mailin_signup_box_row"> |
| 73 | <label><?php echo esc_html_e('Email', 'mailin_i18n'); ?><span class="required">*</span> </label> |
| 74 | <input type="text" id="mailin_email" name="mailin_email" value="<?php echo isset($_POST['mailin_email']) ? $_POST['mailin_email'] : ''; ?>" size="21"> |
| 75 | </div> |
| 76 | <?php |
| 77 | if ($mailin_unsubscribe == 1) |
| 78 | { |
| 79 | ?> |
| 80 | <div class="mailin_signup_box_row"> |
| 81 | <select name="action"> |
| 82 | <option value="1" <?php if(isset($_POST['action']) && $_POST['action'] == 1 ) echo 'selected'; ?> > |
| 83 | <?php |
| 84 | echo esc_html_e('Subscribe', 'mailin_i18n'); |
| 85 | ?> |
| 86 | </option> |
| 87 | <option value="2" |
| 88 | <?php if(isset($_POST['action']) && $_POST['action'] == 2) echo 'selected'; ?>> |
| 89 | <?php |
| 90 | echo esc_html_e('Unsubscribe', 'mailin_i18n'); |
| 91 | ?> |
| 92 | </option> |
| 93 | </select> |
| 94 | </div> |
| 95 | <?php |
| 96 | } |
| 97 | ?> |
| 98 | |
| 99 | |
| 100 | <div class="mailin_signup_box_row right"> |
| 101 | <input type="submit" class="button" value="<?php echo esc_html_e('Validate', 'mailin_i18n'); ?>" id="mailin_signup_submit" name="mailin_signup_submit"></div> |
| 102 | </div> |
| 103 | </form> |
| 104 | </div> |
| 105 | |
| 106 | |
| 107 | <?php |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | |
| 112 | class Mailin_Widget extends WP_Widget |
| 113 | { |
| 114 | |
| 115 | /** |
| 116 | * Register widget with WordPress. |
| 117 | */ |
| 118 | public function __construct() |
| 119 | { |
| 120 | parent::__construct('mailin_widget', // Base ID |
| 121 | 'Mailin_Widget', // Name |
| 122 | array( |
| 123 | 'description' => __('Mailin Widget', 'mailin_i18n') |
| 124 | ) // Args |
| 125 | ); |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Front-end display of widget. |
| 130 | * |
| 131 | * @see WP_Widget::widget() |
| 132 | * |
| 133 | * @param array $args Widget arguments. |
| 134 | * @param array $instance Saved values from database. |
| 135 | */ |
| 136 | public function widget($args, $instance) |
| 137 | { |
| 138 | extract($args); |
| 139 | if (!is_array($instance)) |
| 140 | $instance = array(); |
| 141 | getMailinSubscriptionForm(array_merge($args, $instance)); |
| 142 | } |
| 143 | public function form($instance) |
| 144 | { |
| 145 | if (isset($instance['title']) && !empty($instance['title'])) |
| 146 | $title = $instance['title']; |
| 147 | else |
| 148 | $title = 'Subscribe to newsletter'; |
| 149 | if (isset($instance['firstname']) && $instance['firstname'] == 1) |
| 150 | $fchecked = 'checked'; |
| 151 | else if (!isset($instance['firstname'])) |
| 152 | $fchecked = 'checked'; |
| 153 | if (isset($instance['lastname']) && $instance['lastname'] == 2) |
| 154 | $lchecked = 'checked'; |
| 155 | else if (!isset($instance['lastname'])) |
| 156 | $lchecked = 'checked'; |
| 157 | |
| 158 | |
| 159 | ?> |
| 160 | <p><label for="<?php echo $this->get_field_id('title'); ?>" > |
| 161 | <?php _e('Title:'); ?></label> |
| 162 | <input id="<?php echo $this->get_field_id('title'); ?>" |
| 163 | name="<?php echo $this->get_field_name('title');?>" type="text" value="<?php echo $title; ?>" /></p> |
| 164 | |
| 165 | <p><input <?php echo $fchecked; ?> |
| 166 | id="<?php echo $this->get_field_id('firstname'); ?>" |
| 167 | name="<?php echo $this->get_field_name('firstname'); ?>" type="checkbox" value="1" /> |
| 168 | <label for="<?php echo $this->get_field_id('firstname'); ?>"> |
| 169 | <?php _e('Display first name input', 'mailin_i18n'); ?></label></p> |
| 170 | |
| 171 | <p> <input <?php echo $lchecked; ?> |
| 172 | id="<?php echo $this->get_field_id('lastname'); ?>" |
| 173 | name="<?php echo $this->get_field_name('lastname'); ?>" type="checkbox" value="2" /> |
| 174 | <label for="<?php echo $this->get_field_id('lastname'); ?>"> |
| 175 | <?php _e('Display last name input', 'mailin_i18n'); ?></label></p> |
| 176 | |
| 177 | <?php |
| 178 | } |
| 179 | public function update($new_instance, $old_instance) |
| 180 | { |
| 181 | $instance['title'] = strip_tags($new_instance['title']); |
| 182 | $instance['firstname'] = strip_tags($new_instance['firstname']); |
| 183 | $instance['lastname'] = strip_tags($new_instance['lastname']); |
| 184 | |
| 185 | return $instance; |
| 186 | } |
| 187 | } |
| 188 | function mailinRegisterWidgets() |
| 189 | { |
| 190 | register_widget('Mailin_Widget'); |
| 191 | } |
| 192 | |
| 193 | add_action('widgets_init', 'mailinRegisterWidgets'); |
| 194 | |
| 195 | ?> |
| 196 |