WordPress.org

Plugin Directory

Changeset 937172


Ignore:
Timestamp:
06/23/14 13:53:49 (3 years ago)
Author:
iwebsolutions
Message:

Add multiple email address support, save default value when we prepare the option and delete settings when the plugin is uninstalled.

Location:
background-update-notification-email-address/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • background-update-notification-email-address/trunk/README.txt

    r871265 r937172  
    33Tags: admin, manage, plugin, updates, background updates, automatic updates 
    44Requires at least: 3.7 
    5 Tested up to: 3.8.1 
    6 Stable tag: 1.0.3 
     5Tested up to: 3.9.1 
     6Stable tag: 1.1.1 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    1818This plugin is ideal for those who manage WordPress on their clients behalf. The client carries on receiving WordPress emails as before, with automatic background update notifications being redirected to the developers email address specified in this plugins settings. 
    1919 
    20 We originally [published a solution](http://www.iwebsolutions.co.uk/blog/change-wordpress-auto-update-email-address/) following the release of WordPress 3.7.1. This plugin provides a simple interface for setting the email address without having to touch code. **Once installed, navigate to Settings > Update Notifications. From here you can set the email address where background update notifications should be sent to.** 
     20We originally [published a solution](http://www.iwebsolutions.co.uk/blog/change-wordpress-auto-update-email-address/) following the release of WordPress 3.7.1. This plugin provides a simple interface for setting the email address without having to touch code. 
     21 
     22**Once installed, navigate to Settings > Update Notifications. From here you can set the email address where background update notifications should be sent to. Background update notifications can be sent to multiple recipients by entering a comma-separated list of email addresses.** 
    2123 
    2224== Installation == 
     
    4345== Changelog == 
    4446 
     47= 1.1.1 = 
     48* Maintain backwards compatibility with previous option format, accept either a string or array of email addresses. 
     49 
     50= 1.1.0 = 
     51* Add multiple email address support. You can now enter a comma-separated list of email addresses. 
     52* Save default value when we prepare the option. 
     53* Delete settings when the plugin is uninstalled. 
     54 
    4555= 1.0.3 = 
    4656* Move localisation functions to admin file as there are no public facing strings. 
  • background-update-notification-email-address/trunk/admin/class-update-notification-email-address-admin.php

    r871265 r937172  
    155155        $option_values = get_option( $option_name ); 
    156156 
     157        // Set default values. 
     158        $default_values = array( 
     159            'email' => array( get_bloginfo( 'admin_email' ) ), 
     160        ); 
     161 
     162        // Parse option values and discard the rest. 
     163        $data = shortcode_atts( $default_values, $option_values ); 
     164 
    157165        // Prepare option if it does't exist. 
    158166        if ( false == $option_values ) { 
    159             add_option( $option_name ); 
    160         } 
    161  
    162         // Set default values. 
    163         $default_values = array( 
    164             'email' => get_bloginfo( 'admin_email' ), 
    165         ); 
    166  
    167         // Parse option values and discard the rest. 
    168         $data = shortcode_atts( $default_values, $option_values ); 
     167            add_option( $option_name, $data ); 
     168        } 
    169169 
    170170        register_setting( 
     
    190190                'label_for' => 'email', 
    191191                'name' => 'email', 
    192                 'value' => esc_attr( $data['email'] ), 
     192                'value' => is_array( $data['email'] ) ? esc_attr( implode( ', ',  $data['email'] ) ) : esc_attr( $data['email'] ), 
    193193                'option_name' => $option_name, 
    194                 'type' => 'email' 
     194                'type' => 'text' 
    195195            ) 
    196196        ); 
     
    230230 
    231231            // Get fields. 
    232             $email = isset( $input['email'] ) ? $input['email'] : ''; 
     232            $email = isset( $input['email'] ) ? trim( $input['email'] ) : ''; 
    233233 
    234234            // Validate fields. 
     
    236236                add_settings_error( 'email', 'email_error', __( 'An email address is required', $this->plugin_slug ), 'error' ); 
    237237            } else { 
    238                 if ( ! is_email( $email ) ) { 
    239                     add_settings_error( 'email', 'email_error', __( 'A valid email address is required', $this->plugin_slug ), 'error' ); 
    240                 } else { 
    241                     $options['email'] = sanitize_email( $email ); 
     238                $email_addresses = array_filter( array_map( 'trim', explode( ',', $email ) ) ); 
     239                foreach ( $email_addresses as $email_address ) { 
     240                    if ( ! is_email( $email_address ) ) { 
     241                        add_settings_error( 'email', 'email_error', __( 'A valid email address is required', $this->plugin_slug ), 'error' ); 
     242                        break; 
     243                    } 
     244                } 
     245 
     246                $settings_errors = get_settings_errors( 'email' ); 
     247                if ( empty( $settings_errors ) ) { 
     248                    $options['email'] = $email_addresses; 
    242249                } 
    243250            } 
  • background-update-notification-email-address/trunk/public/class-update-notification-email-address.php

    r871265 r937172  
    2626     * @var string 
    2727     */ 
    28     const VERSION = '1.0.3'; 
     28    const VERSION = '1.1.1'; 
    2929 
    3030    /** 
     
    104104 
    105105        // If an email address has been set, override the WordPress default. 
    106         if ( isset( $options['email'] ) && is_email( $options['email'] ) ) { 
     106        if ( isset( $options['email'] ) && ! empty( $options['email'] ) ) { 
    107107            $email['to'] = $options['email']; 
    108108        } 
  • background-update-notification-email-address/trunk/update-notification-email-address.php

    r871265 r937172  
    1616 * Plugin URI: http://wordpress.org/plugins/background-update-notification-email-address/ 
    1717 * Description: Change the email address update notifications are sent to following an automatic background update. 
    18  * Version: 1.0.3 
     18 * Version: 1.1.1 
    1919 * Author: Interactive Web Solutions Ltd 
    2020 * Author URI: http://www.iwebsolutions.co.uk/ 
Note: See TracChangeset for help on using the changeset viewer.