Changeset 2492 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php
- Timestamp:
- 02/10/2016 08:05:09 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
r2454 r2492 1 1 <?php 2 2 /** 3 * W .org login functions and definitions.3 * WP.org login functions and definitions. 4 4 * 5 5 * @package wporg-login … … 46 46 */ 47 47 function wporg_login_replace_css() { 48 $css_file = '/stylesheets/login.css'; 49 wp_deregister_style( 'login' ); 50 wp_register_style( 'login', get_stylesheet_directory_uri() . $css_file, array( 'buttons', 'dashicons', 'open-sans' ), filemtime( __DIR__ . $css_file ) ); 48 wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons', 'l10n' ), 1 ); 51 49 } 52 50 add_action( 'login_init', 'wporg_login_replace_css' ); 53 51 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 52 66 53 /** 67 * Add Google Analytics tracking to login pages.54 * Enqueue scripts and styles. 68 55 */ 69 function wporg_login_analytics() { 70 global $wporg_login_failed_username; 71 ?> 72 <script type="text/javascript"> 73 var _gaq = _gaq || []; 74 _gaq.push(['_setAccount', 'UA-52447-1']); 75 _gaq.push(['_setDomainName', 'wordpress.org']); 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 } ?> 80 (function() { 81 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 82 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 83 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 84 })(); 85 function recordOutboundLink(link, category, action) { 86 _gaq.push(['_trackEvent', category, action]) 87 setTimeout('document.location = "' + link.href + '"', 100); 56 function wporg_login_scripts() { 57 $script_debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; 58 $suffix = $script_debug ? '' : '.min'; 59 60 // Concatenates core scripts when possible. 61 if ( ! $script_debug ) { 62 $GLOBALS['concatenate_scripts'] = true; 63 } 64 65 wp_enqueue_style( 'wporg-normalize', get_template_directory_uri() . '/stylesheets/normalize.css', 3 ); 66 wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons', 'l10n' ), 1 ); 67 68 // No emoji support needed. 69 remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 70 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 71 72 // No Jetpack styles needed. 73 add_filter( 'jetpack_implode_frontend_css', '__return_false' ); 74 75 // No embeds needed. 76 remove_action( 'wp_head','wp_oembed_add_discovery_links' ); 77 remove_action( 'wp_head', 'wp_oembed_add_host_js' ); 88 78 } 89 </script> 90 <?php 91 } 92 add_action( 'wp_footer', 'wporg_login_analytics' ); 93 add_action( 'login_footer', 'wporg_login_analytics' ); 79 add_action( 'wp_enqueue_scripts', 'wporg_login_scripts' );
Note: See TracChangeset
for help on using the changeset viewer.