trace = new QM_Backtrace( array( 'ignore_frames' => 1, ) ); return $handler; } public function dispatch() { if ( ! $this->should_dispatch() ) { return; } require_once $this->qm->plugin_path( 'output/Html.php' ); $switched_locale = function_exists( 'switch_to_locale' ) && switch_to_locale( get_user_locale() ); $stack = array(); $filtered_trace = $this->trace->get_display_trace(); // Ignore the `apply_filters('wp_die_handler')` stack frame: array_shift( $filtered_trace ); foreach ( $filtered_trace as $i => $item ) { $stack[] = QM_Output_Html::output_filename( $item['display'], $item['file'], $item['line'] ); } if ( isset( $filtered_trace[ $i - 1 ] ) ) { $culprit = $filtered_trace[ $i - 1 ]; } else { $culprit = $filtered_trace[ $i ]; } $component = QM_Backtrace::get_frame_component( $culprit ); printf( // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet '', esc_url( includes_url( 'css/dashicons.css' ) ) ); ?> '; echo '

'; echo ''; if ( $component ) { $name = ( 'plugin' === $component->type ) ? $component->context : $component->name; printf( /* translators: %s: Plugin or theme name */ esc_html__( 'This message was triggered by %s.', 'query-monitor' ), '' . esc_html( $name ) . '' ); } echo '

'; echo '

' . esc_html__( 'Call stack:', 'query-monitor' ) . '

'; echo '
    '; echo '
  1. ' . implode( '
  2. ', $stack ) . '
  3. '; // WPCS: XSS ok. echo '
'; echo '

' . esc_html__( 'Query Monitor', 'query-monitor' ) . '

'; echo ''; if ( $switched_locale ) { restore_previous_locale(); } } public function is_active() { if ( ! $this->trace ) { return false; } if ( ! self::user_can_view() ) { return false; } return true; } } function register_qm_dispatcher_wp_die( array $dispatchers, QM_Plugin $qm ) { $dispatchers['wp_die'] = new QM_Dispatcher_WP_Die( $qm ); return $dispatchers; } add_filter( 'qm/dispatchers', 'register_qm_dispatcher_wp_die', 10, 2 );