Changeset 4470 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php
- Timestamp:
- 12/04/2016 05:54:55 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php
r4417 r4470 5 5 * @package wporg-login 6 6 */ 7 8 require __DIR__ . '/functions-restapi.php'; 9 require __DIR__ . '/functions-registration.php'; 7 10 8 11 /** … … 26 29 */ 27 30 function wporg_login_body_class( $classes ) { 28 // $classes[] = 'wporg-responsive'; 29 $classes[] = 'wporg-login'; 31 if ( WP_WPOrg_SSO::$matched_route ) { 32 $classes[] = 'route-' . WP_WPOrg_SSO::$matched_route; 33 } 34 35 // Remove the 404 class.. 36 if ( false !== ( $pos = array_search( 'error404', $classes ) ) ) { 37 unset( $classes[ $pos ] ); 38 } 30 39 return $classes; 31 40 } … … 44 53 */ 45 54 function wporg_login_replace_css() { 46 wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons', 'l10n' ), 2.3);55 wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons', 'l10n' ), '20161204' ); 47 56 } 48 57 add_action( 'login_init', 'wporg_login_replace_css' ); … … 53 62 function wporg_login_scripts() { 54 63 $script_debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; 55 $suffix = $script_debug ? '' : '.min';56 64 57 65 // Concatenates core scripts when possible. … … 61 69 62 70 wp_enqueue_style( 'wporg-normalize', get_template_directory_uri() . '/stylesheets/normalize.css', 3 ); 63 wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons', 'l10n' ), 2.3 ); 64 65 // No emoji support needed. 66 remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 67 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 68 69 // No Jetpack styles needed. 70 add_filter( 'jetpack_implode_frontend_css', '__return_false' ); 71 72 // No embeds needed. 73 remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); 74 remove_action( 'wp_head', 'wp_oembed_add_host_js' ); 71 wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons', 'l10n' ), '20161204' ); 75 72 } 76 73 add_action( 'wp_enqueue_scripts', 'wporg_login_scripts' ); 74 75 function wporg_login_register_scripts() { 76 wp_register_script( 'recaptcha-api', 'https://www.google.com/recaptcha/api.js', array(), '2' ); 77 78 wp_register_script( 'wporg-registration', get_template_directory_uri() . "/js/registration.js", array( 'recaptcha-api', 'jquery' ), '20161114' ); 79 wp_localize_script( 'wporg-registration', 'wporg_registration', array( 80 'rest_url' => esc_url_raw( rest_url( "wporg/v1" ) ) 81 ) ); 82 } 83 add_action( 'init', 'wporg_login_register_scripts' ); 84 85 /** 86 * Avoid sending a 404 header but send a 200 with nocache headers. 87 */ 88 function wporg_login_pre_handle_404( $false, $wp_query ) { 89 $wp_query->set_404(); // Set the query as 404 to avoid things running thinking it's a real page 90 status_header( 200 ); // but return a 200 91 return true; 92 } 93 add_filter( 'pre_handle_404', 'wporg_login_pre_handle_404', 10, 2 ); 94 95 /** 96 * Filters the page template to load wporg-login/$route.php. 97 * 98 * @param array $templates The templates WordPress intends to load. 99 * @return array The templates the theme intends to use. 100 */ 101 function wporg_login_filter_templates( $templates ) { 102 $route = WP_WPOrg_SSO::$matched_route; 103 104 if ( ! $route || 'root' === $route ) { 105 $route = 'login'; 106 } 107 108 return array( "{$route}.php", 'index.php' ); 109 } 110 add_filter( 'index_template_hierarchy', 'wporg_login_filter_templates' ); 111 112 // No emoji support needed. 113 remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 114 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 115 116 // No Jetpack styles needed. 117 add_filter( 'jetpack_implode_frontend_css', '__return_false' ); 118 119 // No embeds needed. 120 remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); 121 remove_action( 'wp_head', 'wp_oembed_add_host_js' ); 122 remove_action( 'rest_api_init', 'wp_oembed_register_route' ); 123 124 // Don't perform any WP_Query queries on this site.. 125 add_filter( 'posts_request', '__return_empty_string' ); 126 // Don't attempt to do canonical lookups.. 127 remove_filter( 'template_redirect', 'redirect_canonical' ); 128 // There's no need to edit the site.. 129 remove_action( 'wp_head', 'wlwmanifest_link' ); 130 remove_action( 'wp_head', 'rsd_link' ); 131 // We don't need all the rest routes either.. 132 remove_action( 'rest_api_init', 'create_initial_rest_routes', 99 ); 133 134 // Don't need all the wp-admin specific user metas on user create/update 135 add_filter( 'insert_user_meta', '__return_empty_array', 1 );
Note: See TracChangeset
for help on using the changeset viewer.