Changeset 1703146
- Timestamp:
- 07/26/2017 01:59:08 PM (7 years ago)
- Location:
- mailgun-subscriptions/trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
mailgun-subscriptions/trunk/Mailgun_Subscriptions/Account_Management_Subscription_Request_Handler.php
r1469692 r1703146 24 24 switch ( $this->action ) { 25 25 case 'account-subscribe': 26 $this->handle_subscribe_request( $this->authenticator->get_email(), $this->submission[ 'list' ] );26 $this->handle_subscribe_request( $this->authenticator->get_email(), $this->submission[ 'list' ] ); 27 27 break; 28 28 case 'account-unsubscribe': … … 39 39 } 40 40 41 private function handle_subscribe_request( $email_address, $list_address ) {41 private function handle_subscribe_request( $email_address, $list_address ) { 42 42 $submission_handler = new Submission_Handler( array( 43 43 'mailgun-lists' => array( $list_address ), 44 44 'mailgun-subscriber-email' => $email_address, 45 45 46 )); 46 47 $submission_handler->handle_request(); -
mailgun-subscriptions/trunk/Mailgun_Subscriptions/Account_Management_Token_Request_Handler.php
r1469692 r1703146 43 43 44 44 private function is_valid_email( $email_address ) { 45 $api = Plugin::instance()->api( true ); 46 return (bool) ( $api->validate_email( $email_address ) ); 45 if ( apply_filters( 'mailgun_subscriptions_validate_email_with_api', false ) ) { 46 $valid = Plugin::instance()->api( TRUE )->validate_email( $email_address ); 47 } else { 48 $valid = is_email( $email_address ); 49 } 50 return (bool) $valid; 47 51 } 48 52 -
mailgun-subscriptions/trunk/Mailgun_Subscriptions/Admin_Page.php
r1489834 r1703146 343 343 $lists = $this->get_mailing_lists_from_cache(); 344 344 $addresses = wp_list_pluck( $lists, 'address' ); 345 $saved = get_option('mailgun_lists');345 $saved = get_option('mailgun_lists'); 346 346 $gone = array_diff( array_keys($saved), $addresses ); 347 347 if ( !empty($gone) ) { -
mailgun-subscriptions/trunk/Mailgun_Subscriptions/Confirmation.php
r994371 r1703146 11 11 protected $post_id = ''; 12 12 protected $address = ''; 13 13 14 protected $confirmed = FALSE; 14 15 protected $lists = array(); … … 43 44 } 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 45 59 46 60 public function save() { … … 51 65 'post_status' => 'publish', 52 66 'post_author' => 0, 53 'post_title' => $this->id,67 'post_title' => , 54 68 'post_name' => $this->id, 55 69 )); … … 57 71 delete_post_meta( $this->post_id, '_mailgun_subscriber_lists' ); 58 72 update_post_meta( $this->post_id, '_mailgun_subscriber_address', $this->address ); 73 59 74 update_post_meta( $this->post_id, '_mailgun_subscription_confirmed', $this->confirmed ); 60 75 foreach ( $this->lists as $list ) { … … 82 97 $this->post_id = reset($results); 83 98 $this->address = get_post_meta($this->post_id, '_mailgun_subscriber_address', true); 99 84 100 $this->lists = get_post_meta($this->post_id, '_mailgun_subscriber_lists', false); 85 101 $this->confirmed = get_post_meta($this->post_id, '_mailgun_subscription_confirmed', true); -
mailgun-subscriptions/trunk/Mailgun_Subscriptions/Confirmation_Handler.php
r1469692 r1703146 70 70 protected function do_subscription() { 71 71 $address = $this->confirmation->get_address(); 72 72 73 $lists = $this->confirmation->get_lists(); 73 74 $api = Plugin::instance()->api(); … … 75 76 $response = $api->post("lists/$list_address/members", array( 76 77 'address' => $address, 78 77 79 'upsert' => 'yes', 78 80 )); -
mailgun-subscriptions/trunk/Mailgun_Subscriptions/Null_Confirmation.php
r994371 r1703146 15 15 16 16 public function get_address() { 17 18 19 20 21 22 23 24 17 25 return ''; 18 26 } -
mailgun-subscriptions/trunk/Mailgun_Subscriptions/Plugin.php
r1489834 r1703146 6 6 7 7 class Plugin { 8 const VERSION = '1. 1.2';8 const VERSION = '1.'; 9 9 10 10 /** @var Plugin */ -
mailgun-subscriptions/trunk/Mailgun_Subscriptions/Shortcode_Handler.php
r1469692 r1703146 65 65 'description' => '', 66 66 'lists' => '', 67 67 68 ), $atts); 68 69 if ( empty($atts['lists']) ) { … … 77 78 'description' => $atts['description'], 78 79 'lists' => $lists, 80 79 81 )); 80 82 return ob_get_clean(); -
mailgun-subscriptions/trunk/Mailgun_Subscriptions/Submission_Handler.php
r1469692 r1703146 60 60 61 61 protected function is_valid_email( $address ) { 62 $valid = Plugin::instance()->api( TRUE )->validate_email( $address ); 62 if ( apply_filters( 'mailgun_subscriptions_validate_email_with_api', false ) ) { 63 $valid = Plugin::instance()->api( TRUE )->validate_email( $address ); 64 } else { 65 $valid = is_email( $address ); 66 } 63 67 if ( !$valid ) { 64 68 $this->error_details['invalid-email'][] = $address; … … 92 96 $confirmation = new Confirmation(); 93 97 $confirmation->set_address($this->get_submitted_address()); 98 94 99 $confirmation->set_lists($this->get_submitted_lists()); 95 100 $confirmation->save(); … … 100 105 $address = isset($this->submission['mailgun-subscriber-email']) ? $this->submission['mailgun-subscriber-email'] : ''; 101 106 return $address; 107 108 109 110 111 102 112 } 103 113 -
mailgun-subscriptions/trunk/Mailgun_Subscriptions/Subscription_Form.php
r1469692 r1703146 117 117 echo '</p>'; 118 118 } 119 120 121 122 123 124 125 119 126 echo '<p class="email-address">'; 120 127 printf( '<label for="mailgun-email-address-%d">%s</label> ', $instance_counter, __('Email Address', 'mailgun-subscriptions') ); … … 124 131 $default_email = $user->user_email; 125 132 } 126 printf( '<input type="text" value="%s" name="mailgun-subscriber-email" size="20" id="mailgun-email-address-%d" />', $default_email, $instance_counter);133 printf( '<input type="text" value="%s" name="mailgun-subscriber-email" size="20" id="mailgun-email-address-%d" ); 127 134 echo '</p>'; 128 135 printf( '<p class="submit"><input type="submit" value="%s" /></p>', apply_filters( 'mailgun_subscription_form_button_label', __('Subscribe', 'mailgun-subscriptions') ) ); … … 169 176 return $url; 170 177 } 171 } 178 } -
mailgun-subscriptions/trunk/Mailgun_Subscriptions/Widget.php
r1469692 r1703146 37 37 'description' => $content, 38 38 'lists' => $instance['lists'], 39 39 40 )); 40 41 … … 51 52 52 53 public function update( $new_instance, $old_instance ) { 53 $instance = $ old_instance;54 $instance = $_instance; 54 55 $instance['title'] = strip_tags($new_instance['title']); 55 $instance['content'] = $new_instance['content'];56 $instance['lists'] = $new_instance['lists'];57 56 return $instance; 58 57 } … … 82 81 <textarea class="widefat" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>"><?php echo esc_textarea($content); ?></textarea></p> 83 82 84 <p><label for="<?php echo $this->get_field_id('lists'); ?>"><?php _e('Options:', 'mailgun-subscriptions'); ?></label> 83 <p> 84 <input class="widefat" id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" type="checkbox" <?php checked(isset($instance['name']) && $instance['name'] === 'on'); ?> /> 85 <label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Require name?', 'mailgun-subscriptions'); ?></label> 86 </p> 87 88 <p><label for="<?php echo $this->get_field_id('lists'); ?>"><?php _e('List Options:', 'mailgun-subscriptions'); ?></label> 85 89 <ul> 86 90 <?php foreach ( Plugin::instance()->get_lists('name') as $list_address => $list_settings ): ?> -
mailgun-subscriptions/trunk/mailgun-subscriptions.php
r1489834 r1703146 6 6 Author: Flightless 7 7 Author URI: http://flightless.us/ 8 Version: 1. 1.28 Version: 1. 9 9 Text Domain: mailgun-subscriptions 10 10 Domain Path: /languages -
mailgun-subscriptions/trunk/readme.md
r1469692 r1703146 13 13 ## Subscription Form Widget 14 14 15 The plugin creates a widget called "Mailgun List Subscription Form". It includes options to set the title, an optional description, and the mailing lists that will be available in the widget.15 The plugin creates a widget called "Mailgun List Subscription Form". It includes options to set the title, an optional description, and the mailing lists that will be available in the widget. 16 16 17 17 ## Shortcode … … 21 21 * `lists` - The email addresses of the lists that should be available in the form. 22 22 * `description` - The description that will display above the form. 23 23 24 24 25 ### Hooks … … 91 92 If a user visits the confirmation page without a valid confirmation URL, an error message will be displayed instead of the standard page contents. 92 93 94 95 96 97 98 99 100 101 102 103 104 -
mailgun-subscriptions/trunk/readme.txt
r1489834 r1703146 3 3 Tags: mailing lists, subscriptions, widget, email 4 4 Requires at least: 3.9 5 Tested up to: 4. 66 Stable tag: 1. 1.25 Tested up to: 4. 6 Stable tag: 1. 7 7 License: GPL-2.0 8 8 License URI: https://opensource.org/licenses/GPL-2.0 … … 20 20 21 21 == Changelog == 22 23 24 25 26 27 22 28 23 29 = 1.1.2 =
Note: See TracChangeset
for help on using the changeset viewer.