Plugin Directory

Changeset 522736


Ignore:
Timestamp:
03/23/2012 05:36:20 PM (14 years ago)
Author:
wmsedgar
Message:

Committing version 1.4.

Location:
wp-user-control/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-user-control/trunk/inc/WPUserControlWidget.php

    r517093 r522736  
    7676        // first get options array from wordpress database
    7777        $arr = get_option(
    78                 $show = 'widget_wp-user-control-widget',
    79                 $default = false
    80         );
     78            $show = 'widget_wp-user-control-widget',
     79            $default = false
     80            );
    8181        // check to see if option array was successfully retrieved
    8282        if ( $arr !== false ) {
     
    107107}
    108108
    109 function wp_user_control_retrieve_password_email( $message, $key ) {
    110     /*
    111      * @todo: set up custom message for retrieve password email
    112      */
    113     return $message;
     109/**
     110 *
     111 * Filter method to set custom email address for sending all WP administrative email.
     112 *
     113 * @param string $from_email
     114 * @return string $from_email
     115 */
     116function wp_user_control_mail_from_filter( $from_email ) {
     117    // first get options array from wordpress database
     118    $arr = get_option(
     119        $show = 'widget_wp-user-control-widget',
     120        $default = false
     121        );
     122    // check to see if option array was successfully retrieved
     123    if ( $arr !== false ) {
     124        // loop through options array from database
     125        foreach ( $arr as $instance_id => $properties ) {
     126            // make sure we're dealing with a valid instance id
     127            if ( is_numeric( $instance_id ) && count( $properties ) > 1 ) {
     128                // if mail from address is stored and not empty, return it
     129                if ( !empty( $properties['mailFromAddress'] ) ) {
     130                    return $properties['mailFromAddress'];
     131                    // otherwise return default mail from
     132                } else {
     133                    return $from_email;
     134                }
     135                // instance id is not valid, or no options are saved, return default login url
     136            } else {
     137                return $from_email;
     138            }
     139        }
     140        // options array was not successfully retrieved, return default login url
     141    } else {
     142        return $from_email;
     143    }
    114144}
    115145
    116 function wp_user_control_password_reset_email( $message, $key ) {
    117     // set global for user_login
    118     /*
    119      * @todo: set up custom message for redirect to custom password reset location
    120      */
    121     /*
    122     global $user_login;
    123     // build the message
    124     $message = __( 'Someone has asked to reset the password for the following site and username.', 'wp-user-control' ) . "\r\n\r\n";
    125     $message .= network_site_url() . "\r\n\r\n";
    126     $message .= sprintf( __( 'Username: %s', 'wp-user-control' ), $user_login ) . "\r\n\r\n";
    127     $message .= __( 'To reset your password visit the following address, otherwise just ignore this email and nothing will happen.', 'wp-user-control' ) . "\r\n\r\n";
    128     $message .= network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . "\r\n";
    129     */
    130     // return the new message
    131     return $message;
     146/**
     147 *
     148 * Filter method to set custom name in from field for all WP administrative email.
     149 *
     150 * @param string $from_name
     151 * @return string $from_name
     152 */
     153function wp_user_control_mail_from_name_filter( $from_name ) {
     154    // first get options array from wordpress database
     155    $arr = get_option(
     156        $show = 'widget_wp-user-control-widget',
     157        $default = false
     158        );
     159    // check to see if option array was successfully retrieved
     160    if ( $arr !== false ) {
     161        // loop through options array from database
     162        foreach ( $arr as $instance_id => $properties ) {
     163            // make sure we're dealing with a valid instance id
     164            if ( is_numeric( $instance_id ) && count( $properties ) > 1 ) {
     165                // if mail from address is stored and not empty, return it
     166                if ( !empty( $properties['mailFromName'] ) ) {
     167                    return $properties['mailFromName'];
     168                    // otherwise return default mail from
     169                } else {
     170                    return $from_name;
     171                }
     172                // instance id is not valid, or no options are saved, return default login url
     173            } else {
     174                return $from_name;
     175            }
     176        }
     177        // options array was not successfully retrieved, return default login url
     178    } else {
     179        return $from_name;
     180    }
    132181}
    133182
     
    193242                ); // hook failed login
    194243           
    195             add_filter(
    196                 $tag = 'password_reset_message',
    197                 $function_to_add = 'wp_user_control_password_reset_email',
    198                 $priority = 10,
    199                 $accepted_args = 2
    200                 ); // hook password reset message filter
    201            
    202             add_filter(
    203                 $tag = 'retrieve_password_message',
    204                 $function_to_add = 'wp_user_control_retrieve_password_email',
    205                 $priority = 10,
    206                 $accepted_args = 2
    207                 ); // hook retrieve password message filter
    208            
    209244            // add filter hooks
    210245            add_filter(
     
    220255                $priority = 10,
    221256                $accepted_args = 3
    222                 ); // hook failed registration           
     257                ); // hook failed registration
     258
     259             add_filter(
     260                $tag = 'wp_mail_from',
     261                $function_to_add = 'wp_user_control_mail_from_filter',
     262                $priority = 10,
     263                $accepted_args = 1
     264                ); // hook mail from address
     265             
     266             add_filter(
     267                $tag = 'wp_mail_from_name',
     268                $function_to_add = 'wp_user_control_mail_from_name_filter',
     269                $priority = 10,
     270                $accepted_args = 1
     271                ); // hook mail from name
    223272           
    224273        } // end constructor method
     
    241290                'loginButtonLabel' =>       __( 'Login', 'wp-user-control' ),
    242291                'loginTabLabel' =>          __( 'Login', 'wp-user-control' ),
     292                'mailFromAddress' =>        get_option( 'admin_email' ),
     293                'mailFromName' =>           get_option( 'blogname' ),
    243294                'resetTabLabel' =>          __( 'Reset', 'wp-user-control' ),
    244295                'resetButtonLabel' =>       __( 'Reset Password', 'wp-user-control' ),
     
    364415                'value' =>          $instance['customLink']
    365416                ) );
     417            // output custom email address field
     418            $this->outputFormField( array(
     419                'class' =>          'widefat',
     420                'label' =>          __( 'From Email Address ', 'wp-user-control' ),
     421                'field' =>          'mailFromAddress',
     422                'type' =>           'text',
     423                'value' =>          $instance['mailFromAddress']
     424                ) );
     425            // output custom email address field
     426            $this->outputFormField( array(
     427                'class' =>          'widefat',
     428                'label' =>          __( 'From Name ', 'wp-user-control' ),
     429                'field' =>          'mailFromName',
     430                'type' =>           'text',
     431                'value' =>          $instance['mailFromName']
     432                ) );
    366433        }
    367434       
     
    392459            $instance['loginTabLabel'] = trim( strip_tags( $new_instance['loginTabLabel'] ) );
    393460            $this->OPTIONS[$this->number]['loginTabLabel'] = $instance['loginTabLabel'];
     461            $instance['mailFromAddress'] = trim( strip_tags( $new_instance['mailFromAddress'] ) );
     462            $this->OPTIONS[$this->number]['mailFromAddress'] = $instance['mailFromAddress'];
     463            $instance['mailFromName'] = trim( strip_tags( $new_instance['mailFromName'] ) );
     464            $this->OPTIONS[$this->number]['mailFromName'] = $instance['mailFromName'];         
    394465            $instance['registerButtonLabel'] = trim( strip_tags( $new_instance['registerButtonLabel'] ) );
    395466            $this->OPTIONS[$this->number]['registerButtonLabel'] = $instance['registerButtonLabel'];
     
    602673                                            // create password reset email message
    603674                                            $message = __('Someone has asked to reset the password for the following site and username.', 'wp-user-control' ) . "\r\n\r\n";
    604                                             $message .= get_option( 'siteurl' ) . "\r\n\r\n";
     675                                            $message .= network_site_url() . "\r\n\r\n";
     676                                            // $message .= get_option( 'siteurl' ) . "\r\n\r\n";
    605677                                            $message .= sprintf( __( 'Username: %s', 'wp-user-control' ), $reset_user_login ) . "\r\n\r\n";
    606                                             $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.', 'wp-user-control' ) . "\r\n\r\n";
    607                                             $message .= get_option( 'siteurl' ) . "/wp-login.php?action=rp&key=$key\r\n";
     678                                            $message .= __( 'To reset your password visit the following address, otherwise just ignore this email and nothing will happen.', 'wp-user-control' ) . "\r\n\r\n";
     679                                            $message .= network_site_url( "wp-login.php?action=rp&key=" . rawurlencode( $key ) . "&login=" . rawurlencode( $reset_user_login ), 'login' ) . "\r\n";
     680                                            // $message .= get_option( 'siteurl' ) . "/wp-login.php?action=rp&key=$key\r\n";
    608681                                            // send password reset email meassage
    609682                                            if ( false == wp_mail( $reset_user_email, sprintf( __( '[%s] Password Reset', 'wp-user-control' ), get_option( 'blogname' ) ), $message ) ) {
  • wp-user-control/trunk/readme.txt

    r519866 r522736  
    55Requires at least: 2.9
    66Tested up to: 3.3.1
    7 Stable tag: 1.3
     7Stable tag: 1.4
    88
    99Add a WordPress login widget that allows a user to login, register, or reset their password, ALL without leaving their current location!
     
    2323<strong>Customization Features</strong>
    2424<ul>
    25     <li>Enables redirect to custom login URL for standard login</li>
    26     <li>Customizable tab labels (login, register, and reset)</li>
    27     <li>Customizable button labels (login, register, and reset)</li>
     25    <li>Customize sender name and email address in WP admin emails</li>
     26    <li>Redirect to custom URL for login</li>
     27    <li>Customize tab & button labels (login, register, and reset)</li>
    2828    <li>Toggle Avatar display</li>
    29     <li>Choose default tab for display (login, register, or reset)</li>
    30     <li>Add a custom link for logged in users after <em>Profile</em> or <em>Admin</em> links</li>
     29    <li>Set default tab (login, register, or reset)</li>
     30    <li>Add custom link for logged in users after <em>Profile</em> or <em>Admin</em> link</li>
    3131    <li>Internationalized and ready for language translation</li>
    3232</ul>
     
    5656Yes, using this setting will affect all logins for the site. Make ABSOLUTELY CERTAIN you are entering a valid URL before saving, or it could cause you problems getting into your site.
    5757
     58= Does the custom sender name and email address affect all administrative emails from my site? =
     59
     60Yes, this setting will take effect for all administrative emails sent from your site. Leave these fields blank to use the default WordPress settings.
     61
    5862== Screenshots ==
    5963
     
    6872
    6973== Changelog ==
     74
     75= 1.4 =
     76* Fixed bug with "invalid key" in links in password reset emails.
     77* Added ability to customize sender name and email address in WP admin emails (registration, reset, etc.).
    7078
    7179= 1.3 =
     
    98106== Upgrade Notice ==
    99107
     108= 1.4 =
     109* IMPORTANT: Fixed bug with "invalid key" in links in password reset emails, also added ability to customize sender name and address in WP admin emails.
     110
    100111= 1.3 =
    101112* Minor bug fixes, added Finnish language translation file.
  • wp-user-control/trunk/wp_uc_widget.php

    r519866 r522736  
    55    Plugin Name: WP User Control
    66    Plugin URI: http://oaktondata.com/wp-user-control/
    7     Version: 1.3
     7    Version: 1.4
    88    Author: Bill Edgar
    99    Author URI: http://oaktondata.com
     
    4343
    4444// define constants
    45 define( 'WP_USER_CONTROL_WIDGET_VERSION', '1.3' );
     45define( 'WP_USER_CONTROL_WIDGET_VERSION', '1.4' );
    4646define( 'WP_USER_CONTROL_WIDGET_BASE_URL', network_site_url() );
    4747
     
    163163           
    164164            remove_filter(
    165                 $tag = 'password_reset_message',
    166                 $function_to_remove = 'wp_user_control_password_reset_email',
    167                 $priority = 10,
    168                 $accepted_args = 2
    169                 ); // remove filter for password reset message
    170            
    171             remove_filter(
    172                 $tag = 'retrieve_password_message',
    173                 $function_to_remove = 'wp_user_control_retrieve_password_email',
    174                 $priority = 10,
    175                 $accepted_args = 2
    176                 ); // remove filter for retrieve password message
    177            
    178             remove_filter(
    179165                $tag = 'registration_errors',
    180166                $function_to_remove = 'wp_user_control_registration_errors_filter',
     
    189175                $accepted_args = 2
    190176                ); // remove filter for custom login url
     177           
     178            remove_filter(
     179                $tag = 'wp_mail_from',
     180                $function_to_remove = 'wp_user_control_mail_from_filter',
     181                $priority = 10,
     182                $accepted_args = 1
     183                ); // remove filter for custom mail from address
     184           
     185            remove_filter(
     186                $tag = 'wp_mail_from_name',
     187                $function_to_remove = 'wp_user_control_mail_from_name_filter',
     188                $priority = 10,
     189                $accepted_args = 1
     190                ); // remove filter for custom mail from name
    191191           
    192192        }
Note: See TracChangeset for help on using the changeset viewer.