Make WordPress Core


Ignore:
Timestamp:
01/16/2019 03:20:04 PM (6 years ago)
Author:
flixos90
Message:

Bootstrap/Load: Fix workaround to display admin link in PHP error template by introducing $link_url and $link_text arguments to wp_die().

This changeset removes the hack that was used before to display more complex HTML markup than a simple message in the default PHP error template via wp_die(). By removing HTML markup from the arguments passed to wp_die() it furthermore paves the way for supporting other content types than the default.

The message and arguments can be modified with new wp_php_error_message and wp_php_error_args filters respectively.

Furthermore this changeset fixes a few issues of functions not existing which could potentially have caused fatal errors when executed early in the WordPress bootstrap process.

Props flixos90, spacedmonkey.
See #45933, #44458.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r44590 r44624  
    29342934 * @since 4.1.0 The `$title` and `$args` parameters were changed to optionally accept
    29352935 *              an integer to be used as the response code.
     2936 * @since 5.1.0 The `$link_url` and `$link_text` arguments were added.
    29362937 *
    29372938 * @param string|WP_Error  $message Optional. Error message. If this is a WP_Error object,
     
    29472948 *
    29482949 *     @type int    $response       The HTTP response code. Default 200 for Ajax requests, 500 otherwise.
     2950 *     @type string $link_url       A URL to include a link to. Only works in combination with $link_text.
     2951 *                                  Default empty string.
     2952 *     @type string $link_text      A label for the link to include. Only works in combination with $link_url.
     2953 *                                  Default empty string.
    29492954 *     @type bool   $back_link      Whether to include a link to go back. Default false.
    29502955 *     @type string $text_direction The text direction. This is only useful internally, when WordPress
     
    30343039    } elseif ( is_string( $message ) ) {
    30353040        $message = "<p>$message</p>";
     3041    }
     3042
     3043    if ( ! empty( $r['link_url'] ) && ! empty( $r['link_text'] ) ) {
     3044        $link_url = $r['link_url'];
     3045        if ( function_exists( 'esc_url' ) ) {
     3046            $link_url = esc_url( $link_url );
     3047        }
     3048        $link_text = $r['link_text'];
     3049        $message  .= "\n<p><a href='{$link_url}'>{$link_text}</a></p>";
    30363050    }
    30373051
Note: See TracChangeset for help on using the changeset viewer.