Plugin Directory

Changeset 932130


Ignore:
Timestamp:
06/14/2014 12:15:56 AM (12 years ago)
Author:
dylanemoore
Message:

Adding version 1.01 of sendwithus plugin

Location:
sendwithus/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • sendwithus/trunk/css/sendwithus_style.css

    r927325 r932130  
    152152    box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
    153153}
     154
     155.test_email_button{
     156    float: right;
     157    margin-top: 2px;
     158    display:none;
     159}
  • sendwithus/trunk/inc/globals.php

    r927325 r932130  
    66$GLOBALS['wp_notifications'] = array(
    77    'new_user'                       => array(
    8         'event'       => 'New User Created - Sent to Administrator',
     8        'event'       => 'New User Created - Sent to Registering User',
    99        'description' => 'Triggered when a new user signs up for an account.',
    1010        'display_parameters' => '<input type="button" class="parameters_button" id="new_user" name="display_parameters" value="Display parameters"',
     
    1616                <li><strong>blog_name</strong> - Name of the blog.</li>
    1717                <li><strong>default_message</strong> - Default WordPress email content.</li>
    18             </ul>'
     18            </ul>',
     19            'test_button' => '<input type="button" class="button test_email_button new_user" id="new_user" name="test_email_button" value="Send test email" style="display:none; margin-top:2px;">'
    1920        /*
    2021        default_message:
     
    4849                <li><strong>blog_name</strong> - Name of the blog.</li>
    4950                <li><strong>default_message</strong> - Default WordPress email content.</li>
    50             </ul>'
     51            </ul>',
     52            'test_button' => '<input type="button" class="button test_email_button new_comment" id="new_comment" name="test_email_button" value=" Send test email " style="display:none; margin-top:2px;">'
    5153        /*
    5254        default_message:
     
    8991                <li><strong>blog_name</strong> - Name of the blog.</li>
    9092                <li><strong>default_message</strong> - Default WordPress email content.</li>
    91             </ul>'
     93            </ul>',
     94            'test_button' => '<input type="button" class="button test_email_button awaiting_approval" id="awaiting_approval" name="test_email_button" value=" Send test email " style="display:none; margin-top:2px;">'
    9295        /*
    9396        default_message:
     
    122125                <li><strong>blog_name</strong> - Name of the blog.</li>
    123126                <li><strong>default_message</strong> - Default WordPress email content.</li>
    124             </ul>'
     127            </ul>',
     128            'test_button' => '<input type="button" class="button test_email_button password_reset" id="password_reset" name="test_email_button" value=" Send test email " style="display:none; margin-top:2px;">'
    125129        /*
    126130        default_message:
     
    155159                <li><strong>blog_name</strong> - Name of the blog.</li>
    156160                <li><strong>default_message</strong> - Default WordPress email content.</li>
    157             </ul>'
     161            </ul>',
     162            'test_button' => '<input type="button" class="button test_email_button password_change_notification" id="password_change_notification" name="test_email_button" value=" Send test email " style="display:none; margin-top:2px;">'
    158163        /*
    159164        default_message:
     
    168173        'event'       => 'New User Activation - Sent to Administrator',
    169174        'description' => 'Triggered when a new user signs up.',
    170         'display_parameters' => '<input type="button" class="parameters_button" id="ms_new_user_network_admin" name="display_parameters" value="Display parameters"',
     175        'display_parameters' => '<input type="button" class="parameters_button" id="ms_new_user_network_admin" name="display_parameters" value="Display parameters">',
    171176        'parameters'  => '
    172177            <ul>
     
    175180                <li><strong>control_panel</strong> - WordPress control panel URL.</li>
    176181                <li><strong>default_message</strong> - The default WordPress email content.</li>
    177             </ul>' 
     182            </ul>',
     183        'test_button' => '<input type="button" class="button test_email_button ms_new_user_network_admin" id="ms_new_user_network_admin" name="test_email_button" value=" Send test email " style="display:none; margin-top:2px;">'
    178184        /*
    179185        default_message:
     
    196202                <li><strong>control_panel</strong> -  WordPress control panel URL.</li>
    197203                <li><strong>default_message</strong> - The default WordPress email content.</li>
    198             </ul>'       
     204            </ul>',
     205            'test_button' => '<input type="button" class="button test_email_button ms_new_blog_network_admin" id="ms_new_blog_network_admin" name="test_email_button" value=" Send test email " style="display:none; margin-top:2px;">'       
    199206        /*
    200207        default_message:
     
    218225                <li><strong>site_name</strong> - Blog\'s name.
    219226                <li><strong>default_message</strong> - The default WordPress email content.</li>
    220             </ul>'       
     227            </ul>',
     228            'test_button' => '<input type="button" class="button test_email_button ms_welcome_user_notification" id="ms_welcome_user_notification" name="test_email_button" value=" Send test email " style="display:none; margin-top:2px;">'
    221229        /*
    222230        default_message:
     
    246254                <li><strong>site_url</strong> - New blog\'s URL.</li>
    247255                <li><strong>default_message</strong> - The default WordPress email content.</li>
    248             </ul>'
     256            </ul>',
     257            'test_button' => '<input type="button" class="button test_email_button ms_welcome_notification" id="ms_welcome_notification" name="test_email_button" value=" Send test email " style="display:none; margin-top:2px;">'
    249258        /*
    250259        default_message:
     
    278287                <li><strong>content</strong> - Unformatted version of default_message, with no domain/path or links.</li>
    279288                <li><strong>default_message</strong> - The default WordPress email content.</li>
    280             </ul>'       
     289            </ul>',
     290            'test_button' => '<input type="button" class="button test_email_button ms_signup_blog_verification" id="ms_signup_blog_verification" name="test_email_button" value=" Send test email " style="display:none; margin-top:2px;">'       
    281291        /*
    282292        default_message:
     
    302312                <li><strong>blog_url</strong> - URL of the blog the user signed up for.</li>
    303313                <li><strong>default_message</strong> - The default WordPress email content.</li>
    304             </ul>'
     314            </ul>',
     315            'test_button' => '<input type="button" class="button test_email_button ms_signup_user_notification" id="ms_signup_user_notification" name="test_email_button" value=" Send test email " style="display:none; margin-top:2px;">'
    305316
    306317        /*
  • sendwithus/trunk/inc/helper_functions.php

    r929995 r932130  
    66// Wrapper for the emails() function in the API
    77function get_templates() {
    8     $template_names = [];
    9     $api_key = get_option('api_key');
     8    if(is_network_admin()) {
     9        $api_key = get_site_option( 'api_key' );
     10    } else {
     11        $api_key = get_option( 'api_key' );
     12    }
    1013    $api = new \sendwithus\API($api_key);
    1114    $response = $api->emails();
     
    1922}
    2023
     24// Function for creating a default template if there isn't one already (Single Site Instance)
    2125function create_default_template(){
    2226    $active_templates = get_templates();
    23    
     27
    2428    $api_key = get_option('api_key');
    2529    $api = new \sendwithus\API($api_key);
     
    3539            $default_deleted = false;
    3640        }
     41        if($current->name == 'Default Wordpress email'){
     42            update_option('default_wordpress_email_id', $current->id);
     43            return;
     44        }
    3745    }
    3846
    3947    //If the default wordpress template id isn't in the array
    40     if( $default_id == "" || $default_deleted ) {
     48    if($default_id == "" || $default_deleted){
    4149        //Create a new template for default wordpress emails
    4250        $response = $api->create_email('Default Wordpress email',
     
    5058    }
    5159}
     60// Function for creating a default template if there isn't one already (Multi Site Instance)
     61function ms_create_default_template(){
     62    $active_templates = get_templates();
     63
     64    $api_key = get_site_option('api_key');
     65    $api = new \sendwithus\API($api_key);
     66    $response = $api->emails();
     67
     68    //Get the default wordpress email template ID
     69    $default_id = get_site_option('ms_default_wordpress_email_id');
     70    $default_deleted = true;
     71
     72    // Ensure that the default template hasn't been deleted.
     73    foreach ( $active_templates as $current ) {
     74        if ( $current->id == $default_id && $default_id != "" ) {
     75            $default_deleted = false;
     76        }
     77        if($current->name == 'Default Wordpress email'){
     78            update_site_option('ms_default_wordpress_email_id', $current->id);
     79            return;
     80        }
     81    }
     82
     83    //If the default wordpress template id isn't in the array
     84    if($default_id == "" || $default_deleted){
     85        //Create a new template for default wordpress emails
     86        $response = $api->create_email('Default Wordpress email',
     87                    '{{default_email_subject}} ',
     88                    '<html><head></head><body>{{default_message}}</body></html>');
     89
     90        // Only save if the response is good.
     91        if ( is_object($response) ) {
     92            update_site_option('ms_default_wordpress_email_id', $response->id);
     93        }
     94    }
     95}
    5296
    5397// Get the API key for use as a global variable.
    5498function get_api_key() {
     99    if(is_network_admin()){
     100        return get_site_option('api_key');
     101    }
    55102    return get_option('api_key');
    56103}
     
    59106function generate_template_selection($name, $array) {
    60107    $input_code = '<select name="' . $name . '" style="width: 100%">';
    61     $current_template = get_option($name);
     108    if(is_network_admin()) {
     109        $current_template = get_site_option( $name );
     110    } else {
     111        $current_template = get_option( $name );
     112    }
    62113
    63114    // Assign it to the default if no template is returned.
    64115    if($current_template == "") {
    65         $current_template = get_option('default_wordpress_email_id');
     116        if(is_network_admin()){
     117            $current_template = get_site_option('ms_default_wordpress_email_id');
     118        } else {
     119            $current_template = get_option('default_wordpress_email_id');
     120        }
    66121    }
    67122
     
    89144        echo '<tr><td colspan="2" style="padding-top: 0px;">';
    90145        echo generate_parameter_listing($current, $text);
     146        echo generate_test_button($text);
    91147        echo '</td></tr>';
    92148    }
     
    102158}
    103159
     160function generate_test_button($text){
     161    $test_button = $text['test_button'];
     162    return $test_button;
     163}
     164
    104165// Make 'default_message' HTML friendly.
    105166function html_default_message($default_message) {
     
    110171// Used to create an area to save plugin settings.
    111172function sendwithus_register_settings() {
    112     // Make sure the default template ID doesn't get overwritten!
    113     $default_id = get_option('default_wordpress_email_id');
    114     register_setting( 'sendwithus_settings', 'default_wordpress_email_id');
    115     update_option('default_wordpress_email_id', $default_id);
     173    //Use site_option if we are using a multisite instance
     174    if ( is_network_admin() ) { // Only change site options if network admin
     175        $default_id = get_site_option( 'ms_default_wordpress_email_id' );
     176        update_site_option( 'ms_default_wordpress_email_id', $default_id );
     177    }
     178    else{
     179        // Make sure the default template ID doesn't get overwritten!
     180        $default_id = get_option('default_wordpress_email_id');
     181        register_setting( 'sendwithus_settings', 'default_wordpress_email_id');
     182        update_option('default_wordpress_email_id', $default_id);
     183    }
    116184
    117185    // Save settings within wp_options table as 'sendwithus_settings'
     
    131199
    132200    foreach ( $GLOBALS['wp_ms_notifications'] as $key => $value ) {
    133         register_setting( 'sendwithus_settings', $key );
    134 
    135         if ( get_option($key) == "" ) {
     201        register_setting( 'sendwithus_settings', $key );
     202
     203        if ( get_site_option($key) == "" ) {
    136204            // Assign default template.
    137             update_option($key, $default_id);     
    138         }
    139     }
     205            update_site_option($key, $default_id);
     206        }
     207    }
     208}
     209
     210add_action('network_admin_edit_reg_settings','register_network_admin_settings');
     211function register_network_admin_settings(){
     212    update_site_option('api_key', $_POST['api_key']);
     213
     214    // Multisite Options
     215    update_site_option('ms_new_user_network_admin',    $_POST['ms_new_user_network_admin']);
     216    update_site_option('ms_new_blog_network_admin',    $_POST['ms_new_blog_network_admin']);
     217    update_site_option('ms_welcome_user_notification', $_POST['ms_welcome_user_notification']);
     218    update_site_option('ms_welcome_notification',      $_POST['ms_welcome_notification']);
     219    update_site_option('ms_signup_blog_verification',  $_POST['ms_signup_blog_verification']);
     220    update_site_option('ms_signup_user_notification',  $_POST['ms_signup_user_notification']);
     221
     222    wp_redirect(network_admin_url("admin.php?page=sendwithus.php&updated=true"));
     223
     224    exit;
    140225}
    141226
     
    216301}
    217302
     303add_action( 'wp_ajax_test_email', 'send_test_email');
     304function send_test_email(){
     305
     306    $current_user = wp_get_current_user();
     307    if(isset($_POST['email']) && !empty($_POST['email'])) {
     308        $action = $_POST['email'];
     309        switch($action) {
     310            case 'new_user':
     311                wp_new_user_notification(get_current_user_id(), 'N/A');
     312                break;
     313            case 'new_comment':
     314                $comment_id = create_test_comment();
     315                wp_notify_postauthor($comment_id);
     316                wp_delete_comment( $comment_id, true );
     317                break;
     318            case 'awaiting_approval':
     319                $comment_id = create_test_comment();
     320                wp_notify_moderator($comment_id);
     321                wp_delete_comment( $comment_id, true );
     322                break;
     323            case 'password_reset':
     324                $message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n";
     325                $message .= network_home_url( '/' ) . "\r\n\r\n";
     326                $message .= sprintf(__('Username: %s'), $current_user->user_login) . "\r\n\r\n";
     327                $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n";
     328                $message .= __('To reset your password, visit the following address:') . "\r\n\r\n";
     329                $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode( $current_user->user_login), 'login') . ">\r\n";
     330                apply_filters('retrieve_password_message',$message,'N/A',get_current_user_id());
     331                break;
     332            case 'password_change_notification':
     333                wp_password_change_notification($current_user);
     334                echo $current_user->user_login;
     335                break;
     336            case 'ms_new_user_network_admin':
     337                newuser_notify_siteadmin(get_current_user_id());
     338                break;
     339            case 'ms_new_blog_network_admin':
     340                newblog_notify_siteadmin('');
     341                break;
     342            case 'ms_welcome_user_notification':
     343                wpmu_welcome_user_notification(get_current_user_id(), 'N/A');
     344                break;
     345            case 'ms_welcome_notification':
     346                wpmu_welcome_notification(1,get_current_user_id(), 'N/A', 'Test blog');
     347                break;
     348            case 'ms_signup_blog_verification':
     349                $content = "Dear User, activate your new site here: http://{domain}{$path}wp-activate.php?key=$key";
     350                apply_filters('wpmu_signup_blog_notification_email',$content,'Test Domain', get_bloginfo('url'), get_bloginfo('name'), $current_user->user_login, $current_user->user_email, 'N/A');
     351                break;
     352            case 'ms_signup_user_notification':
     353                $content = "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\n";
     354                apply_filters('wpmu_signup_user_notification_email',$content, $current_user->user_login, $current_user->user_email, 'N/A');
     355                break;
     356            default:
     357                break;
     358        }
     359    }
     360
     361    die();
     362}
     363
     364function create_test_comment(){
     365    $data = array(
     366        'comment_post_ID' => 1,
     367        'comment_author' => 'admin',
     368        'comment_author_email' => 'admin@admin.com',
     369        'comment_author_url' => 'http://',
     370        'comment_content' => 'content here',
     371        'comment_type' => '',
     372        'comment_parent' => 0,
     373        'user_id' => 1,
     374        'comment_author_IP' => '127.0.0.1',
     375        'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)',
     376        'comment_date' => $time,
     377        'comment_approved' => 1,
     378    );
     379
     380    return wp_insert_comment($data);
     381}
     382
    218383// Creates link to plugin settings in WordPress control panel.
    219384add_action( 'admin_menu', 'activate_sidebar_shortcut' );
     
    226391}
    227392
     393// Creates link to plugin settings in Network Administrator Control Panel
     394add_action('network_admin_menu', 'activate_network_sidebar_shortcut');
     395function activate_network_sidebar_shortcut() {
     396    // Add the shortcut for the plugin settings underneath the 'plugins' sidebar menu.
     397    add_menu_page( 'sendwithus', 'sendwithus', 'manage_options', 'sendwithus.php', 'sendwithus_conf_main', 'dashicons-email-alt' );
     398
     399    // Create an area in WordPress to store the settings saved by the user.
     400    add_action( 'admin_init', 'sendwithus_register_settings' );
     401}
     402
     403/*
     404add_action('network_admin_menu', 'activate_sidebar_shortcut_network_admin');
     405function activate_sidebar_shortcut_network_admin(){
     406    add_menu_page( 'sendwithus', 'sendwithus', 'manage_options', 'sendwithus.php', 'sendwithus_conf_main', 'dashicons-email-alt' );
     407}
     408*/
    228409// Warn the user if their api key is invalid
    229410add_action( 'admin_notices', 'sendwithus_no_api_key_warning' );
  • sendwithus/trunk/inc/multisite_overrides.php

    r929995 r932130  
    99
    1010// Filter for when a new user has been activated - notify the network admin.
    11 add_filter("newuser_notify_siteadmin", "swu_newuser_notify_siteadmin", 10, 2);
     11add_filter("newuser_notify_siteadmin", "swu_newuser_notify_siteadmin", 11, 2);
    1212function swu_newuser_notify_siteadmin($default_message, $user) {
    13     $api = new \sendwithus\API($GLOBALS['api_key']);   
     13    $api_key = get_site_option('api_key');
     14    $api = new \sendwithus\API($api_key);
    1415
    1516    $email = get_site_option( 'admin_email' );
    1617    $options_site_url = esc_url(network_admin_url('settings.php'));
    1718    $remote_ip = wp_unslash( $_SERVER['REMOTE_ADDR'] );
    18     $default_email_subject = "New user ".$user->user_login." created at ".$site_name[1];
    19     $response = $api->send(
    20         get_option('ms_new_user_network_admin'),
     19    if(isset($site_name[1])){
     20        $default_email_subject = "New user " . $user->user_login . " created at ". $site_name[1];
     21    }
     22    else{
     23        $default_email_subject = "New user " . $user->user_login . " created.";
     24    }
     25    $response = $api->send(
     26        get_site_option('ms_new_user_network_admin'),
    2127        array('address' => $email),
    2228        array(
     
    3743add_filter("newblog_notify_siteadmin", "swu_newblog_notify_siteadmin", 10, 1);
    3844function swu_newblog_notify_siteadmin($default_message) {
    39     $api = new \sendwithus\API($GLOBALS['api_key']);
     45    $api_key = get_site_option('api_key');
     46    $api = new \sendwithus\API($api_key);
    4047
    4148    // Extract pertinent information from the message.
     
    4855    $email = get_site_option( 'admin_email' );
    4956    //Subject line for default wordpress email
    50     $default_email_subject = "New blog ".get_option('blogname')." created at ".$site_name[1];
    51     $response = $api->send(
    52         get_option('ms_new_blog_network_admin'),
     57    $default_email_subject = "New blog ".$site_name[1]." created at ".get_option('blogname');
     58    $response = $api->send(
     59        get_site_option('ms_new_blog_network_admin'),
    5360        array('address' => $email),
    5461        array(
     
    6875
    6976add_filter("wpmu_welcome_user_notification", "swu_wpmu_welcome_user_notification", 10, 3);
    70 function swu_wpmu_welcome_user_notification( $user_id, $password, $meta ) {
    71     $api = new \sendwithus\API($GLOBALS['api_key']);
     77function swu_wpmu_welcome_user_notification( $user_id, $password, $meta = '' ) {
     78    $api_key = get_site_option('api_key');
     79    $api = new \sendwithus\API($api_key);
    7280
    7381    $user  = get_userdata( $user_id );
     
    93101
    94102    $response = $api->send(
    95         get_option('ms_welcome_user_notification'),
     103        get_site_option('ms_welcome_user_notification'),
    96104        array('address' => $user->user_email),
    97105        array(
     
    109117    return false;
    110118}
    111 
     119//Sent to user when a blog is created for them on multisite
    112120add_filter("wpmu_welcome_notification", "swu_wpmu_welcome_notification", 10, 5);
    113121function swu_wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta ) {
    114     $api = new \sendwithus\API($GLOBALS['api_key']);
     122    $api_key = get_site_option('api_key');
     123    $api = new \sendwithus\API($api_key);
     124
    115125    $current_site = get_current_site();
    116     $url = get_blogaddress_by_id($blog_id);
    117     $user = get_userdata( $user_id );
    118126
    119127    $admin_email = get_site_option( 'admin_email' );
     
    144152    $user = get_userdata( $user_id );
    145153
    146     $default_message = str_replace( 'SITE_NAME', $current_site->site_name, $default_message );
     154    $default_message = str_replace( 'SITE_NAME',  $current_site->site_name, $default_message );
    147155    $default_message = str_replace( 'BLOG_TITLE', $title, $default_message );
    148     $default_message = str_replace( 'BLOG_URL', $url, $default_message );
    149     $default_message = str_replace( 'USERNAME', $user->user_login, $default_message );
    150     $default_message = str_replace( 'PASSWORD', $password, $default_message );
     156    $default_message = str_replace( 'BLOG_URL',   $url, $default_message );
     157    $default_message = str_replace( 'USERNAME',   $user->user_login, $default_message );
     158    $default_message = str_replace( 'PASSWORD',   $password, $default_message );
    151159 
    152160    //Subject line for default wordpress email
    153     $default_email_subject = get_option('blogname'). " has been added to your multisite instance";
    154 
    155     $response = $api->send(
    156         get_option('ms_welcome_notification'),
     161    $default_email_subject = "Your site ".$title." has been added to ".get_option('blogname');
     162
     163    $response = $api->send(
     164        get_site_option('ms_welcome_notification'),
    157165        array('address' => $user->user_email),
    158166        array(
     
    160168                'default_email_subject' => $default_email_subject,
    161169                'user_email' => $user->user_email,
    162                 'user_password' => $password,
     170                'user_password' => $user->password,
    163171                'admin_email' => $admin_email,
    164172                'site_name' => $current_site->site_name,
     
    174182// Filter for when a new signup has been successful. Used when site registration is enabled.
    175183add_filter("wpmu_signup_blog_notification_email", "swu_wpmu_signup_blog_notification", 10, 8);
    176 function swu_wpmu_signup_blog_notification($content, $domain, $path, $title, $user, $user_email, $key, $meta) {
    177     $api = new \sendwithus\API($GLOBALS['api_key']);
     184function swu_wpmu_signup_blog_notification($content, $domain, $path, $title, $user, $user_email, $key, $meta = '') {
     185    $api_key = get_site_option('api_key');
     186    $api = new \sendwithus\API($api_key);
    178187
    179188    // Generate the activation link.
     
    196205
    197206    $response = $api->send(
    198         get_option('ms_signup_blog_verification'),
     207        get_site_option('ms_signup_blog_verification'),
    199208        array('address' => $user_email),
    200209        array(
     
    219228add_filter( 'wpmu_signup_user_notification_email', 'swu_wpmu_signup_user_notification', 10, 5 );
    220229function swu_wpmu_signup_user_notification($content, $user, $user_email, $key, $meta = '') {
    221     $api = new \sendwithus\API($GLOBALS['api_key']);
     230    $api_key = get_site_option('api_key');
     231    $api = new \sendwithus\API($api_key);
    222232
    223233    $blog_name = get_bloginfo('name');
    224234    $blog_url = network_site_url();
    225235
    226     $message = '/wp-activate.php?key='. $key; 
     236    $message = '/wp-activate.php?key='. $key;
    227237    $url = network_site_url($message);
    228238
     
    230240
    231241    //Subject line for default wordpress email
    232     $default_email_subject = "A new user has signed up at ".get_option('blogname');
    233 
    234     $response = $api->send(
    235         get_option('ms_signup_user_notification'),
     242    $default_email_subject = "A new user has signed up at " . $blog_name;
     243
     244    $response = $api->send(
     245        get_site_option('ms_signup_user_notification'),
    236246        array('address' => $user_email),
    237247        array(
  • sendwithus/trunk/inc/single_site_overrides.php

    r927325 r932130  
    9393if (!function_exists('wp_new_user_notification')) {
    9494    function wp_new_user_notification($user_id, $plaintext_pass = "") {
     95        // Stops the user from receiving a redundant email in multisite mode
     96        if(is_network_admin()){
     97            return;
     98        }
    9599        $user = new WP_User($user_id);
    96100
     
    262266
    263267// Adds a function to occur when the filter retrieve_password_message is called
    264 add_filter ("retrieve_password_message", "reset_password_notification", 10, 2 );
    265 function reset_password_notification($content, $key) {
    266     //Grabs the information about the user attempting to reset their password
    267     $input = filter_input( INPUT_POST, 'user_login', FILTER_SANITIZE_STRING );
    268 
    269     if( is_email( $input ) ) {
    270         $user = get_user_by( 'email', $input );
    271     } else {
    272         $user = get_user_by( 'login', sanitize_user( $input ) );
    273     }
    274 
    275     $user_info = get_userdata($user->ID);
    276 
     268add_filter ("retrieve_password_message", "reset_password_notification", 10, 3 );
     269function reset_password_notification($content, $key, $user_login_id = NULL) {
     270    if($user_login_id != NULL){
     271        $user = get_userdata($user_login_id);
     272    }
     273    else{
     274        //Grabs the information about the user attempting to reset their password
     275        $input = filter_input( INPUT_POST, 'user_login', FILTER_SANITIZE_STRING );   
     276        if( is_email( $input ) ) {
     277            $user = get_user_by( 'email', $input );
     278        } else {
     279            $user = get_user_by( 'login', sanitize_user( $input ) );
     280        }
     281
     282        $user_info = get_userdata($user->ID);
     283    }
     284
     285    echo $user->user_login;
    277286    //Creates a string to hold the end section of the password reset link
    278287    $message = 'wp-login.php?action=rp&key='. $key. '&login='.$user->user_login;
     
    307316    );
    308317
     318
    309319    return false;
    310320}
  • sendwithus/trunk/readme.txt

    r929995 r932130  
    11=== sendwithus ===
    22Contributors: yokelpole, freshcelery, dylanemoore
    3 Tags: email, transactional, sendwithus
     3Tags: email, transactional, sendwithus, sendgrid, mandrill, mailgun, message bus, postmark, multisite, network
    44Requires at least: 3.9.0
    55Tested up to: 3.9.1
     
    5353
    5454= 1.01 =
    55 * Bugfixes
     55* Some bugfixes
     56* Multisite configuration is now saner
    5657
    5758= 1.0 =
  • sendwithus/trunk/sendwithus.php

    r929995 r932130  
    22/**
    33 * @package sendwithus
    4  * @version 1.0
     4 * @version 1.01
    55 */
    66/*
     
    99Description: Easily integrate transactional email into WordPress' default emails.
    1010Author: Dylan Moore, Kyle Poole, and Cory Purnell
    11 Version: 1.0
     11Version: 1.01
    1212Author URI: http://www.sendwithus.com
    1313*/
     
    2828set_globals();
    2929
     30if(is_network_admin()){
     31    $GLOBALS['api_key'] = get_site_option('api_key');
     32}
     33
    3034if ( $GLOBALS['api_key'] == '' || $GLOBALS['templates']->status == 'error' ) {
    3135    $GLOBALS['valid_key'] = false;
     
    3337    // Establish whether an API key has been entered and that it is valid.
    3438    $GLOBALS['valid_key'] = true;
    35 
    36     add_action( 'init', 'create_default_template');
    37 
    38     // Some sites don't work with muplugins_loaded for some reason.
    39     // This will make default be created.
    40     if ( did_action('create_default_template') == 0 ) {
    41         add_action( 'plugins_loaded', 'create_default_template');
     39    if(is_network_admin()){
     40        add_action( 'init', 'ms_create_default_template');
     41        // Some sites don't work with muplugins_loaded for some reason.
     42        // This will make default be created.
     43        if ( did_action('create_default_template') == 0 ) {
     44           add_action( 'plugins_loaded', 'ms_create_default_template');
     45        }
    4246    }
    43 
     47    else{
     48        add_action( 'init', 'create_default_template');     
     49        // Some sites don't work with muplugins_loaded for some reason.
     50        // This will make default be created.
     51        if ( did_action('create_default_template') == 0 ) {
     52           add_action( 'plugins_loaded', 'create_default_template');
     53        }
     54    }
    4455    add_action( 'plugins_loaded', 'set_globals');
    4556}
     
    92103        <!-- A check should be performed before loading the table to ensure that the user
    93104             has entered an API key - otherwise only an entry for API key should be displayed. -->
     105        <?php if ( is_network_admin() ) : ?>
     106        <form action="edit.php?action=reg_settings" method="post">
     107
     108        <? else : ?>
    94109        <form action="options.php" method="post">
     110        <? endif ?>
    95111            <?php
    96112            // Load up the previously saved settings.
     
    100116
    101117            <!-- Hidden input containing default template ID -->
     118            <?php if ( is_network_admin() ) : ?><!-- Just for the network admin-->
     119                <input id="default_wordpress_email_id" name="default_wordpress_email_id"
     120                       style="display: none;" value="<?php echo get_site_option('default_wordpress_email_id'); ?>" />
     121
     122            <?php else : ?>
    102123            <input id="default_wordpress_email_id" name="default_wordpress_email_id"
    103124                style="display: none;" value="<?php echo get_option('default_wordpress_email_id'); ?>" />
     125            <?php endif ?>
    104126
    105127            <!-- Only display if API key is populated -->
     
    126148
    127149            <!-- Only display if API key is populated -->
    128             <?php if ( $GLOBALS['valid_key'] ) : ?>
     150            <?php if ( $GLOBALS['valid_key']) : ?>
     151                <?php if(!is_network_admin()) : ?>
    129152                <table class="wp-list-table widefat sendwithus_table">
    130                     <?php if ( is_multisite() ) : ?>
    131                         <thead>
    132                         <th colspan="2">
    133                             <p class="table_description">Single-site Events</p>
    134                             <p class="description" style="text-align: center;">
    135                                 Single-site events occur on all WordPress installations. They are primarly concerned with user and comment moderation.
    136                             </p>
    137                         </th>
    138                         </thead>
    139                     <?php endif; ?>
    140153                    <?php generate_template_table( $GLOBALS['wp_notifications'] ); ?>
    141154                </table>
     155                <?php endif ?>
    142156                <!-- Events that are displayed when multisite events are enabled -->
    143                 <?php if ( is_multisite() ) : ?>
     157                <?php if ( is_network_admin() ) : ?>
    144158                    <table class="multisite wp-list-table widefat" id="multisite_table">
    145159                        <thead>
     
    190204                var className = event.target.classList[3];
    191205                $('.parameters.' + className).slideToggle(150);
     206                $('.test_email_button.' + className).slideToggle(150);
     207            });
     208
     209            $('.test_email_button').click(function(){
     210                var className = this.classList[2];
     211                var data = { action : 'test_email',
     212                          email : className}
     213                $.post(ajaxurl, data, function(response){
     214                    alert(response);
     215                });
    192216            });
    193217
     
    198222            });
    199223
     224
    200225            // Used to get rid of the 'welcome' message that pops up.
    201226            $('#dismiss_message').click(function() {
Note: See TracChangeset for help on using the changeset viewer.