Plugin Directory

Changeset 1703146

Timestamp:
07/26/2017 01:59:08 PM (7 years ago)
Author:
jbrinley
Message:

Version 1.2.0

Location:
mailgun-subscriptions/trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • mailgun-subscriptions/trunk/Mailgun_Subscriptions/Account_Management_Subscription_Request_Handler.php

    r1469692 r1703146  
    2424            switch ( $this->action ) {
    2525                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' ] );
    2727                    break;
    2828                case 'account-unsubscribe':
     
    3939    }
    4040
    41     private function handle_subscribe_request( $email_address, $list_address ) {
     41    private function handle_subscribe_request( $email_address, $list_address ) {
    4242        $submission_handler = new Submission_Handler( array(
    4343            'mailgun-lists' => array( $list_address ),
    4444            'mailgun-subscriber-email' => $email_address,
     45
    4546        ));
    4647        $submission_handler->handle_request();
  • mailgun-subscriptions/trunk/Mailgun_Subscriptions/Account_Management_Token_Request_Handler.php

    r1469692 r1703146  
    4343
    4444    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;
    4751    }
    4852
  • mailgun-subscriptions/trunk/Mailgun_Subscriptions/Admin_Page.php

    r1489834 r1703146  
    343343        $lists = $this->get_mailing_lists_from_cache();
    344344        $addresses = wp_list_pluck( $lists, 'address' );
    345         $saved = get_option('mailgun_lists');
     345        $saved = get_option('mailgun_lists');
    346346        $gone = array_diff( array_keys($saved), $addresses );
    347347        if ( !empty($gone) ) {
  • mailgun-subscriptions/trunk/Mailgun_Subscriptions/Confirmation.php

    r994371 r1703146  
    1111    protected $post_id = '';
    1212    protected $address = '';
     13
    1314    protected $confirmed = FALSE;
    1415    protected $lists = array();
     
    4344    }
    4445
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
    4559
    4660    public function save() {
     
    5165                'post_status' => 'publish',
    5266                'post_author' => 0,
    53                 'post_title' => $this->id,
     67                'post_title' => ,
    5468                'post_name' => $this->id,
    5569            ));
     
    5771        delete_post_meta( $this->post_id, '_mailgun_subscriber_lists' );
    5872        update_post_meta( $this->post_id, '_mailgun_subscriber_address', $this->address );
     73
    5974        update_post_meta( $this->post_id, '_mailgun_subscription_confirmed', $this->confirmed );
    6075        foreach ( $this->lists as $list ) {
     
    8297        $this->post_id = reset($results);
    8398        $this->address = get_post_meta($this->post_id, '_mailgun_subscriber_address', true);
     99
    84100        $this->lists = get_post_meta($this->post_id, '_mailgun_subscriber_lists', false);
    85101        $this->confirmed = get_post_meta($this->post_id, '_mailgun_subscription_confirmed', true);
  • mailgun-subscriptions/trunk/Mailgun_Subscriptions/Confirmation_Handler.php

    r1469692 r1703146  
    7070    protected function do_subscription() {
    7171        $address = $this->confirmation->get_address();
     72
    7273        $lists = $this->confirmation->get_lists();
    7374        $api = Plugin::instance()->api();
     
    7576            $response = $api->post("lists/$list_address/members", array(
    7677                'address' => $address,
     78
    7779                'upsert' => 'yes',
    7880            ));
  • mailgun-subscriptions/trunk/Mailgun_Subscriptions/Null_Confirmation.php

    r994371 r1703146  
    1515
    1616    public function get_address() {
     17
     18
     19
     20
     21
     22
     23
     24
    1725        return '';
    1826    }
  • mailgun-subscriptions/trunk/Mailgun_Subscriptions/Plugin.php

    r1489834 r1703146  
    66
    77class Plugin {
    8     const VERSION = '1.1.2';
     8    const VERSION = '1.';
    99
    1010    /** @var Plugin */
  • mailgun-subscriptions/trunk/Mailgun_Subscriptions/Shortcode_Handler.php

    r1469692 r1703146  
    6565            'description' => '',
    6666            'lists' => '',
     67
    6768        ), $atts);
    6869        if ( empty($atts['lists']) ) {
     
    7778            'description' => $atts['description'],
    7879            'lists' => $lists,
     80
    7981        ));
    8082        return ob_get_clean();
  • mailgun-subscriptions/trunk/Mailgun_Subscriptions/Submission_Handler.php

    r1469692 r1703146  
    6060
    6161    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        }
    6367        if ( !$valid ) {
    6468            $this->error_details['invalid-email'][] = $address;
     
    9296        $confirmation = new Confirmation();
    9397        $confirmation->set_address($this->get_submitted_address());
     98
    9499        $confirmation->set_lists($this->get_submitted_lists());
    95100        $confirmation->save();
     
    100105        $address = isset($this->submission['mailgun-subscriber-email']) ? $this->submission['mailgun-subscriber-email'] : '';
    101106        return $address;
     107
     108
     109
     110
     111
    102112    }
    103113
  • mailgun-subscriptions/trunk/Mailgun_Subscriptions/Subscription_Form.php

    r1469692 r1703146  
    117117            echo '</p>';
    118118        }
     119
     120
     121
     122
     123
     124
     125
    119126        echo '<p class="email-address">';
    120127        printf( '<label for="mailgun-email-address-%d">%s</label> ', $instance_counter, __('Email Address', 'mailgun-subscriptions') );
     
    124131            $default_email = $user->user_email;
    125132        }
    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" );
    127134        echo '</p>';
    128135        printf( '<p class="submit"><input type="submit" value="%s" /></p>', apply_filters( 'mailgun_subscription_form_button_label', __('Subscribe', 'mailgun-subscriptions') ) );
     
    169176        return $url;
    170177    }
    171 } 
     178}
  • mailgun-subscriptions/trunk/Mailgun_Subscriptions/Widget.php

    r1469692 r1703146  
    3737            'description' => $content,
    3838            'lists' => $instance['lists'],
     39
    3940        ));
    4041
     
    5152
    5253    public function update( $new_instance, $old_instance ) {
    53         $instance = $old_instance;
     54        $instance = $_instance;
    5455        $instance['title'] = strip_tags($new_instance['title']);
    55         $instance['content'] = $new_instance['content'];
    56         $instance['lists'] = $new_instance['lists'];
    5756        return $instance;
    5857    }
     
    8281            <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>
    8382
    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>
    8589            <ul>
    8690                <?php foreach ( Plugin::instance()->get_lists('name') as $list_address => $list_settings ): ?>
  • mailgun-subscriptions/trunk/mailgun-subscriptions.php

    r1489834 r1703146  
    66Author: Flightless
    77Author URI: http://flightless.us/
    8 Version: 1.1.2
     8Version: 1.
    99Text Domain: mailgun-subscriptions
    1010Domain Path: /languages
  • mailgun-subscriptions/trunk/readme.md

    r1469692 r1703146  
    1313## Subscription Form Widget
    1414
    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.
     15The 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.
    1616
    1717## Shortcode
     
    2121* `lists` - The email addresses of the lists that should be available in the form.
    2222* `description` - The description that will display above the form.
     23
    2324
    2425### Hooks
     
    9192If a user visits the confirmation page without a valid confirmation URL, an error message will be displayed instead of the standard page contents.
    9293
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
  • mailgun-subscriptions/trunk/readme.txt

    r1489834 r1703146  
    33Tags: mailing lists, subscriptions, widget, email
    44Requires at least: 3.9
    5 Tested up to: 4.6
    6 Stable tag: 1.1.2
     5Tested up to: 4.
     6Stable tag: 1.
    77License: GPL-2.0
    88License URI: https://opensource.org/licenses/GPL-2.0
     
    2020
    2121== Changelog ==
     22
     23
     24
     25
     26
     27
    2228
    2329= 1.1.2 =
Note: See TracChangeset for help on using the changeset viewer.