collector->get_data(); /** @var QM_Collector_DB_Queries|null $db_queries */ $db_queries = QM_Collectors::get( 'db_queries' ); /** @var QM_Collector_Raw_Request|null $raw_request */ $raw_request = QM_Collectors::get( 'raw_request' ); $this->before_non_tabular_output(); foreach ( array( 'request' => __( 'Request', 'query-monitor' ), 'matched_rule' => __( 'Matched Rule', 'query-monitor' ), 'matched_query' => __( 'Matched Query', 'query-monitor' ), 'query_string' => __( 'Query String', 'query-monitor' ), ) as $item => $name ) { if ( is_admin() && ! isset( $data->request[ $item ] ) ) { continue; } if ( ! empty( $data->request[ $item ] ) ) { if ( in_array( $item, array( 'request', 'matched_query', 'query_string' ), true ) ) { $value = self::format_url( $data->request[ $item ] ); } else { $value = esc_html( $data->request[ $item ] ); } } else { $value = '' . esc_html__( 'none', 'query-monitor' ) . ''; } echo '
'; echo '

' . esc_html( $name ) . '

'; echo '

' . $value . '

'; // WPCS: XSS ok. echo '
'; } echo ''; echo '
'; if ( ! empty( $data->matching_rewrites ) ) { echo '
'; echo '

' . esc_html__( 'All Matching Rewrite Rules', 'query-monitor' ) . '

'; echo ''; foreach ( $data->matching_rewrites as $rule => $query ) { $query = str_replace( 'index.php?', '', $query ); echo ''; echo ''; echo ''; echo ''; } echo '
' . esc_html( $rule ) . ''; echo self::format_url( $query ); // WPCS: XSS ok. echo '
'; echo '
'; } echo '
'; echo '

'; esc_html_e( 'Query Vars', 'query-monitor' ); echo '

'; if ( $db_queries ) { $db_queries_data = $db_queries->get_data(); if ( ! empty( $db_queries_data->wpdb->has_main_query ) ) { echo '

'; echo self::build_filter_trigger( 'db_queries', 'caller', 'qm-main-query', esc_html__( 'View Main Query', 'query-monitor' ) ); // WPCS: XSS ok; echo '

'; } } if ( ! empty( $data->qvars ) ) { echo ''; foreach ( $data->qvars as $var => $value ) { echo ''; if ( isset( $data->plugin_qvars[ $var ] ) ) { echo ''; } else { echo ''; } echo ''; } echo '
' . esc_html( $var ) . ''; } else { echo '' . esc_html( $var ) . ''; } if ( is_array( $value ) || is_object( $value ) ) { echo '
';
					echo esc_html( print_r( $value, true ) );
					echo '
' . esc_html( $value ) . '
'; } else { echo '

' . esc_html__( 'none', 'query-monitor' ) . '

'; } echo '
'; echo '
'; echo '

' . esc_html__( 'Response', 'query-monitor' ) . '

'; echo '

' . esc_html__( 'Queried Object', 'query-monitor' ) . '

'; if ( ! empty( $data->queried_object ) ) { $class = get_class( $data->queried_object['data'] ); $class = $class ?: __( 'Unknown', 'query-monitor' ); printf( '

%1$s (%2$s)

', esc_html( $data->queried_object['title'] ), esc_html( $class ) ); } else { echo '

' . esc_html__( 'none', 'query-monitor' ) . '

'; } echo '

' . esc_html__( 'Current User', 'query-monitor' ) . '

'; if ( ! empty( $data->user['data'] ) ) { printf( // WPCS: XSS ok. '

%s

', esc_html( $data->user['title'] ) ); } else { echo '

' . esc_html__( 'none', 'query-monitor' ) . '

'; } if ( ! empty( $data->multisite ) ) { echo '

' . esc_html__( 'Multisite', 'query-monitor' ) . '

'; foreach ( $data->multisite as $var => $value ) { printf( // WPCS: XSS ok. '

%s

', esc_html( $value['title'] ) ); } } echo '
'; if ( ! empty( $raw_request ) ) { /** @var QM_Data_Raw_Request $raw_data */ $raw_data = $raw_request->get_data(); echo '
'; echo '

' . esc_html__( 'Request Data', 'query-monitor' ) . '

'; echo ''; foreach ( array( 'ip' => __( 'Remote IP', 'query-monitor' ), 'method' => __( 'HTTP method', 'query-monitor' ), 'url' => __( 'Requested URL', 'query-monitor' ), ) as $item => $name ) { echo ''; echo ''; echo ''; } echo '
' . esc_html( $name ) . ''; echo '' . esc_html( $raw_data->request[ $item ] ) . '
'; echo '
'; } $this->after_non_tabular_output(); } /** * @param array $menu * @return array */ public function admin_menu( array $menu ) { /** @var QM_Data_Request $data */ $data = $this->collector->get_data(); $count = isset( $data->plugin_qvars ) ? count( $data->plugin_qvars ) : 0; $title = ( empty( $count ) ) ? __( 'Request', 'query-monitor' ) /* translators: %s: Number of additional query variables */ : __( 'Request (+%s)', 'query-monitor' ); $menu[ $this->collector->id() ] = $this->menu( array( 'title' => esc_html( sprintf( $title, number_format_i18n( $count ) ) ), ) ); return $menu; } } /** * @param array $output * @param QM_Collectors $collectors * @return array */ function register_qm_output_html_request( array $output, QM_Collectors $collectors ) { $collector = QM_Collectors::get( 'request' ); if ( $collector ) { $output['request'] = new QM_Output_Html_Request( $collector ); } return $output; } add_filter( 'qm/outputter/html', 'register_qm_output_html_request', 60, 2 );