Changeset 2454 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php
- Timestamp:
- 02/03/2016 10:43:25 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php
r2453 r2454 53 53 54 54 /** 55 * Log failed logins to Google Analytics. 56 */ 57 $wporg_login_failed_username = ''; 58 function wporg_login_failed( $errors ) { 59 global $wporg_login_failed_username; 60 $wporg_login_failed_username = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : ''; 61 62 return $errors; 63 } 64 add_action( 'wp_login_errors', 'wporg_login_failed', 10, 1 ); 65 66 /** 55 67 * Add Google Analytics tracking to login pages. 56 68 */ 57 69 function wporg_login_analytics() { 58 ?> 70 global $wporg_login_failed_username; 71 ?> 59 72 <script type="text/javascript"> 60 73 var _gaq = _gaq || []; … … 62 75 _gaq.push(['_setDomainName', 'wordpress.org']); 63 76 _gaq.push(['_trackPageview']); 77 <?php if ( $wporg_login_failed_username ) { ?> 78 _gaq.push(['_trackEvent', 'user', 'login-failed', '<?php echo $wporg_login_failed_username; ?>']); 79 <?php } ?> 64 80 (function() { 65 81 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; … … 72 88 } 73 89 </script> 74 <?php90 <?php 75 91 } 76 add_action( 'wp_footer', 'wporg_login_analytics' ); 92 add_action( 'wp_footer', 'wporg_login_analytics' ); 93 add_action( 'login_footer', 'wporg_login_analytics' );
Note: See TracChangeset
for help on using the changeset viewer.