Making WordPress.org


Ignore:
Timestamp:
04/08/2019 08:28:06 AM (5 years ago)
Author:
dd32
Message:

Login: Output GTM code on wp_die() pages too.

This isn't horribly correct, as it outputs the <link> and GTM code inside a <p> tag, but it does the job for the rare page load.

Fixes #4371.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php

    r8606 r8607  
    8484add_action( 'init', 'wporg_login_register_scripts' );
    8585
     86/**
     87 * Output the GoogleTagManager <head> tags.
     88 */
    8689function wporg_login_gtm() {
    8790    ?>
     
    97100add_action( 'wp_head', 'wporg_login_gtm' );
    98101add_action( 'login_head', 'wporg_login_gtm' );
     102
     103/**
     104 * wp_die() handler for login.wordpress.org, adds GTM to error pages.
     105 */
     106function wporg_login_die_handler( $message, $title = '', $args = array() ) {
     107    ob_start();
     108    wporg_login_gtm();
     109    $gtm = ob_get_clean();
     110
     111    $message = $gtm . $message;
     112    return _default_wp_die_handler( $message, $title, $args );
     113}
     114
     115/**
     116 * Switch the default WP_Die handler for login.wordpress.org to one that includes GTM.
     117 */
     118function wp_die_handler_switcher( $handler ) {
     119    if ( $handler == '_default_wp_die_handler' ) {
     120        $handler = 'wporg_login_die_handler';
     121    }
     122
     123    return $handler;
     124}
     125add_filter( 'wp_die_handler', 'wp_die_handler_switcher' );
    99126
    100127/**
Note: See TracChangeset for help on using the changeset viewer.