Changeset 932130
- Timestamp:
- 06/14/2014 12:15:56 AM (12 years ago)
- Location:
- sendwithus/trunk
- Files:
-
- 7 edited
-
css/sendwithus_style.css (modified) (1 diff)
-
inc/globals.php (modified) (13 diffs)
-
inc/helper_functions.php (modified) (11 diffs)
-
inc/multisite_overrides.php (modified) (12 diffs)
-
inc/single_site_overrides.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
sendwithus.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sendwithus/trunk/css/sendwithus_style.css
r927325 r932130 152 152 box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); 153 153 } 154 155 .test_email_button{ 156 float: right; 157 margin-top: 2px; 158 display:none; 159 } -
sendwithus/trunk/inc/globals.php
r927325 r932130 6 6 $GLOBALS['wp_notifications'] = array( 7 7 'new_user' => array( 8 'event' => 'New User Created - Sent to Administrator',8 'event' => 'New User Created - Sent to Registering User', 9 9 'description' => 'Triggered when a new user signs up for an account.', 10 10 'display_parameters' => '<input type="button" class="parameters_button" id="new_user" name="display_parameters" value="Display parameters"', … … 16 16 <li><strong>blog_name</strong> - Name of the blog.</li> 17 17 <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;">' 19 20 /* 20 21 default_message: … … 48 49 <li><strong>blog_name</strong> - Name of the blog.</li> 49 50 <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;">' 51 53 /* 52 54 default_message: … … 89 91 <li><strong>blog_name</strong> - Name of the blog.</li> 90 92 <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;">' 92 95 /* 93 96 default_message: … … 122 125 <li><strong>blog_name</strong> - Name of the blog.</li> 123 126 <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;">' 125 129 /* 126 130 default_message: … … 155 159 <li><strong>blog_name</strong> - Name of the blog.</li> 156 160 <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;">' 158 163 /* 159 164 default_message: … … 168 173 'event' => 'New User Activation - Sent to Administrator', 169 174 '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">', 171 176 'parameters' => ' 172 177 <ul> … … 175 180 <li><strong>control_panel</strong> - WordPress control panel URL.</li> 176 181 <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;">' 178 184 /* 179 185 default_message: … … 196 202 <li><strong>control_panel</strong> - WordPress control panel URL.</li> 197 203 <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;">' 199 206 /* 200 207 default_message: … … 218 225 <li><strong>site_name</strong> - Blog\'s name. 219 226 <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;">' 221 229 /* 222 230 default_message: … … 246 254 <li><strong>site_url</strong> - New blog\'s URL.</li> 247 255 <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;">' 249 258 /* 250 259 default_message: … … 278 287 <li><strong>content</strong> - Unformatted version of default_message, with no domain/path or links.</li> 279 288 <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;">' 281 291 /* 282 292 default_message: … … 302 312 <li><strong>blog_url</strong> - URL of the blog the user signed up for.</li> 303 313 <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;">' 305 316 306 317 /* -
sendwithus/trunk/inc/helper_functions.php
r929995 r932130 6 6 // Wrapper for the emails() function in the API 7 7 function 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 } 10 13 $api = new \sendwithus\API($api_key); 11 14 $response = $api->emails(); … … 19 22 } 20 23 24 // Function for creating a default template if there isn't one already (Single Site Instance) 21 25 function create_default_template(){ 22 26 $active_templates = get_templates(); 23 27 24 28 $api_key = get_option('api_key'); 25 29 $api = new \sendwithus\API($api_key); … … 35 39 $default_deleted = false; 36 40 } 41 if($current->name == 'Default Wordpress email'){ 42 update_option('default_wordpress_email_id', $current->id); 43 return; 44 } 37 45 } 38 46 39 47 //If the default wordpress template id isn't in the array 40 if( $default_id == "" || $default_deleted ){48 if($default_id == "" || $default_deleted){ 41 49 //Create a new template for default wordpress emails 42 50 $response = $api->create_email('Default Wordpress email', … … 50 58 } 51 59 } 60 // Function for creating a default template if there isn't one already (Multi Site Instance) 61 function 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 } 52 96 53 97 // Get the API key for use as a global variable. 54 98 function get_api_key() { 99 if(is_network_admin()){ 100 return get_site_option('api_key'); 101 } 55 102 return get_option('api_key'); 56 103 } … … 59 106 function generate_template_selection($name, $array) { 60 107 $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 } 62 113 63 114 // Assign it to the default if no template is returned. 64 115 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 } 66 121 } 67 122 … … 89 144 echo '<tr><td colspan="2" style="padding-top: 0px;">'; 90 145 echo generate_parameter_listing($current, $text); 146 echo generate_test_button($text); 91 147 echo '</td></tr>'; 92 148 } … … 102 158 } 103 159 160 function generate_test_button($text){ 161 $test_button = $text['test_button']; 162 return $test_button; 163 } 164 104 165 // Make 'default_message' HTML friendly. 105 166 function html_default_message($default_message) { … … 110 171 // Used to create an area to save plugin settings. 111 172 function 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 } 116 184 117 185 // Save settings within wp_options table as 'sendwithus_settings' … … 131 199 132 200 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) == "" ) { 136 204 // Assign default template. 137 update_option($key, $default_id); 138 } 139 } 205 update_site_option($key, $default_id); 206 } 207 } 208 } 209 210 add_action('network_admin_edit_reg_settings','register_network_admin_settings'); 211 function 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; 140 225 } 141 226 … … 216 301 } 217 302 303 add_action( 'wp_ajax_test_email', 'send_test_email'); 304 function 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 364 function 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 218 383 // Creates link to plugin settings in WordPress control panel. 219 384 add_action( 'admin_menu', 'activate_sidebar_shortcut' ); … … 226 391 } 227 392 393 // Creates link to plugin settings in Network Administrator Control Panel 394 add_action('network_admin_menu', 'activate_network_sidebar_shortcut'); 395 function 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 /* 404 add_action('network_admin_menu', 'activate_sidebar_shortcut_network_admin'); 405 function activate_sidebar_shortcut_network_admin(){ 406 add_menu_page( 'sendwithus', 'sendwithus', 'manage_options', 'sendwithus.php', 'sendwithus_conf_main', 'dashicons-email-alt' ); 407 } 408 */ 228 409 // Warn the user if their api key is invalid 229 410 add_action( 'admin_notices', 'sendwithus_no_api_key_warning' ); -
sendwithus/trunk/inc/multisite_overrides.php
r929995 r932130 9 9 10 10 // Filter for when a new user has been activated - notify the network admin. 11 add_filter("newuser_notify_siteadmin", "swu_newuser_notify_siteadmin", 1 0, 2);11 add_filter("newuser_notify_siteadmin", "swu_newuser_notify_siteadmin", 11, 2); 12 12 function 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); 14 15 15 16 $email = get_site_option( 'admin_email' ); 16 17 $options_site_url = esc_url(network_admin_url('settings.php')); 17 18 $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'), 21 27 array('address' => $email), 22 28 array( … … 37 43 add_filter("newblog_notify_siteadmin", "swu_newblog_notify_siteadmin", 10, 1); 38 44 function 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); 40 47 41 48 // Extract pertinent information from the message. … … 48 55 $email = get_site_option( 'admin_email' ); 49 56 //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'), 53 60 array('address' => $email), 54 61 array( … … 68 75 69 76 add_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']); 77 function swu_wpmu_welcome_user_notification( $user_id, $password, $meta = '' ) { 78 $api_key = get_site_option('api_key'); 79 $api = new \sendwithus\API($api_key); 72 80 73 81 $user = get_userdata( $user_id ); … … 93 101 94 102 $response = $api->send( 95 get_ option('ms_welcome_user_notification'),103 get_site_option('ms_welcome_user_notification'), 96 104 array('address' => $user->user_email), 97 105 array( … … 109 117 return false; 110 118 } 111 119 //Sent to user when a blog is created for them on multisite 112 120 add_filter("wpmu_welcome_notification", "swu_wpmu_welcome_notification", 10, 5); 113 121 function 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 115 125 $current_site = get_current_site(); 116 $url = get_blogaddress_by_id($blog_id);117 $user = get_userdata( $user_id );118 126 119 127 $admin_email = get_site_option( 'admin_email' ); … … 144 152 $user = get_userdata( $user_id ); 145 153 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 ); 147 155 $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 ); 151 159 152 160 //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'), 157 165 array('address' => $user->user_email), 158 166 array( … … 160 168 'default_email_subject' => $default_email_subject, 161 169 'user_email' => $user->user_email, 162 'user_password' => $ password,170 'user_password' => $user->password, 163 171 'admin_email' => $admin_email, 164 172 'site_name' => $current_site->site_name, … … 174 182 // Filter for when a new signup has been successful. Used when site registration is enabled. 175 183 add_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']); 184 function 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); 178 187 179 188 // Generate the activation link. … … 196 205 197 206 $response = $api->send( 198 get_ option('ms_signup_blog_verification'),207 get_site_option('ms_signup_blog_verification'), 199 208 array('address' => $user_email), 200 209 array( … … 219 228 add_filter( 'wpmu_signup_user_notification_email', 'swu_wpmu_signup_user_notification', 10, 5 ); 220 229 function 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); 222 232 223 233 $blog_name = get_bloginfo('name'); 224 234 $blog_url = network_site_url(); 225 235 226 $message = '/wp-activate.php?key='. $key; 236 $message = '/wp-activate.php?key='. $key; 227 237 $url = network_site_url($message); 228 238 … … 230 240 231 241 //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'), 236 246 array('address' => $user_email), 237 247 array( -
sendwithus/trunk/inc/single_site_overrides.php
r927325 r932130 93 93 if (!function_exists('wp_new_user_notification')) { 94 94 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 } 95 99 $user = new WP_User($user_id); 96 100 … … 262 266 263 267 // 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 268 add_filter ("retrieve_password_message", "reset_password_notification", 10, 3 ); 269 function 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; 277 286 //Creates a string to hold the end section of the password reset link 278 287 $message = 'wp-login.php?action=rp&key='. $key. '&login='.$user->user_login; … … 307 316 ); 308 317 318 309 319 return false; 310 320 } -
sendwithus/trunk/readme.txt
r929995 r932130 1 1 === sendwithus === 2 2 Contributors: yokelpole, freshcelery, dylanemoore 3 Tags: email, transactional, sendwithus 3 Tags: email, transactional, sendwithus, sendgrid, mandrill, mailgun, message bus, postmark, multisite, network 4 4 Requires at least: 3.9.0 5 5 Tested up to: 3.9.1 … … 53 53 54 54 = 1.01 = 55 * Bugfixes 55 * Some bugfixes 56 * Multisite configuration is now saner 56 57 57 58 = 1.0 = -
sendwithus/trunk/sendwithus.php
r929995 r932130 2 2 /** 3 3 * @package sendwithus 4 * @version 1.0 4 * @version 1.01 5 5 */ 6 6 /* … … 9 9 Description: Easily integrate transactional email into WordPress' default emails. 10 10 Author: Dylan Moore, Kyle Poole, and Cory Purnell 11 Version: 1.0 11 Version: 1.01 12 12 Author URI: http://www.sendwithus.com 13 13 */ … … 28 28 set_globals(); 29 29 30 if(is_network_admin()){ 31 $GLOBALS['api_key'] = get_site_option('api_key'); 32 } 33 30 34 if ( $GLOBALS['api_key'] == '' || $GLOBALS['templates']->status == 'error' ) { 31 35 $GLOBALS['valid_key'] = false; … … 33 37 // Establish whether an API key has been entered and that it is valid. 34 38 $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 } 42 46 } 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 } 44 55 add_action( 'plugins_loaded', 'set_globals'); 45 56 } … … 92 103 <!-- A check should be performed before loading the table to ensure that the user 93 104 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 : ?> 94 109 <form action="options.php" method="post"> 110 <? endif ?> 95 111 <?php 96 112 // Load up the previously saved settings. … … 100 116 101 117 <!-- 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 : ?> 102 123 <input id="default_wordpress_email_id" name="default_wordpress_email_id" 103 124 style="display: none;" value="<?php echo get_option('default_wordpress_email_id'); ?>" /> 125 <?php endif ?> 104 126 105 127 <!-- Only display if API key is populated --> … … 126 148 127 149 <!-- 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()) : ?> 129 152 <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; ?>140 153 <?php generate_template_table( $GLOBALS['wp_notifications'] ); ?> 141 154 </table> 155 <?php endif ?> 142 156 <!-- Events that are displayed when multisite events are enabled --> 143 <?php if ( is_ multisite() ) : ?>157 <?php if ( is_network_admin() ) : ?> 144 158 <table class="multisite wp-list-table widefat" id="multisite_table"> 145 159 <thead> … … 190 204 var className = event.target.classList[3]; 191 205 $('.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 }); 192 216 }); 193 217 … … 198 222 }); 199 223 224 200 225 // Used to get rid of the 'welcome' message that pops up. 201 226 $('#dismiss_message').click(function() {
Note: See TracChangeset
for help on using the changeset viewer.