コード例 #1
0
 private function load()
 {
     $this->body_params = parent::get_post_meta_array('body_params');
     $this->query_params = parent::get_post_meta_array('query_params');
 }
コード例 #2
0
 public function __construct($post = null)
 {
     parent::__construct('response', $post);
 }
コード例 #3
0
if (!defined('ABSPATH')) {
    die('restricted access');
}
$id = absint(filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT));
$post_type_object = get_post_type_object(WP_REST_API_Log_DB::POST_TYPE);
if (!current_user_can($post_type_object->cap->read_post, $id)) {
    wp_die('<h1>' . __('Cheatin&#8217; uh?') . '</h1>' . '<p>' . __('You are not allowed to read posts in this post type.', 'wp-rest-api-log') . '</p>', 403);
}
if (!empty($id)) {
    $entry = new WP_REST_API_Log_Entry($id);
}
if (empty($entry->ID)) {
    wp_die('<h1>' . esc_html_e('Invalid WP REST API Log Entry ID', 'wp-rest-api-log') . '</h1>', 404);
}
// HTML encode some of the values for display in the admin partial.
$entry = WP_REST_API_Log_API_Request_Response_Base::esc_html_fields($entry);
$entry = apply_filters('wp-rest-api-log-display-entry', $entry);
$body_content = !empty($entry->request->body) ? $entry->request->body : '';
if ('ElasticPress' === $entry->source) {
    // these request bodies are base64 encoded JSON
    if (!empty($body_content)) {
        $body_object = json_decode(base64_decode($body_content));
        $body_content = '';
    }
}
$json_display_options = array('request' => array('headers' => !empty($entry->request->headers) ? JSON_PRETTY_PRINT : 0, 'query_params' => !empty($entry->request->query_params) ? JSON_PRETTY_PRINT : 0, 'body_params' => !empty($entry->request->body_params) ? JSON_PRETTY_PRINT : 0), 'response' => array('headers' => !empty($entry->response->headers) ? JSON_PRETTY_PRINT : 0));
$json_display_options = apply_filters('wp-rest-api-log-json-display-options', $json_display_options, $entry);
$classes = apply_filters('wp-rest-api-log-entry-display-classes', array('wrap', 'wp-rest-api-log-entry'), $entry);
?>
<div class="<?php 
echo implode(' ', array_map('esc_attr', $classes));