Plugin Directory

Changeset 2286528


Ignore:
Timestamp:
04/18/2020 08:07:46 PM (6 years ago)
Author:
mgibbs189
Message:

Tagged 1.2

Location:
log-http-requests/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • log-http-requests/trunk/assets/css/admin.css

    r2022732 r2286528  
    99}
    1010
     11.widefat .field-status-code,
    1112.widefat .field-runtime,
    1213.widefat .field-date {
     
    3334.http-request-args,
    3435.http-response {
    35     max-height: 360px;
     36    max-height: 300px;
    3637    font-family: monospace;
    3738    white-space: pre;
     
    7374}
    7475
     76.media-modal.open,
     77.media-modal-backdrop.open {
     78    display: block;
     79}
     80
    7581.media-frame-title,
    7682.media-frame-content {
     
    9399}
    94100
     101.button-link.media-modal-close.prev {
     102    margin-right: 60px;
     103}
     104
     105.button-link.media-modal-close.next {
     106    margin-right: 30px;
     107}
     108
     109.media-modal-close.prev .media-modal-icon::before {
     110    content: "\f342";
     111}
     112
     113.media-modal-close.next .media-modal-icon::before {
     114    content: "\f346";
     115}
     116
    95117.modal-content-wrap {
    96118    padding: 16px;
  • log-http-requests/trunk/assets/js/admin.js

    r1698896 r2286528  
    2424                            <div><a href="javascript:;" data-id="` + idx + `">` + row.url + `</a></div>
    2525                        </td>
     26                        <td class="field-status-code">` + row.status_code + `</td>
    2627                        <td class="field-runtime` + css_class + `">` + row.runtime + `</td>
    27                         <td class="field-date">` + row.date_added + `</td>
     28                        <td class="field-date" title="` + row.date_raw + `">` + row.date_added + `</td>
    2829                    </tr>
    2930                    `;
     
    4849        }
    4950
     51        LHR.show_details = function(action) {
     52            var id = LHR.active_id;
     53
     54            if ('next' == action && id < LHR.response.rows.length - 1) {
     55                id = id + 1;
     56            }
     57            else if ('prev' == action && id > 0) {
     58                id = id - 1;
     59            }
     60
     61            LHR.active_id = id;
     62
     63            var data = LHR.response.rows[id];
     64            $('.http-url').text(data.url);
     65            $('.http-request-id').text(id);
     66            $('.http-request-args').text(JSON.stringify(JSON.parse(data.request_args), null, 2));
     67            $('.http-response').text(JSON.stringify(JSON.parse(data.response), null, 2));
     68            $('.media-modal').addClass('open');
     69            $('.media-modal-backdrop').addClass('open'); 
     70        }
     71
    5072        // Page change
    5173        $(document).on('click', '.lhr-page:not(.active)', function() {
     
    5678        // Open detail modal
    5779        $(document).on('click', '.field-url a', function() {
    58             var id = parseInt($(this).attr('data-id'));
    59             var data = LHR.response.rows[id];
    60             $('.http-request-args').text(JSON.stringify(JSON.parse(data.request_args), null, 2));
    61             $('.http-response').text(JSON.stringify(JSON.parse(data.response), null, 2));
    62             $('.media-modal').show();
    63             $('.media-modal-backdrop').show();
     80            LHR.active_id = parseInt($(this).attr('data-id'));
     81            LHR.show_details('curr');
    6482        });
    6583
    6684        // Close modal window
    6785        $(document).on('click', '.media-modal-close', function() {
    68             $('.media-modal').hide();
    69             $('.media-modal-backdrop').hide();
     86            var $this = $(this);
     87
     88            if ($this.hasClass('prev') || $this.hasClass('next')) {
     89                var action = $this.hasClass('prev') ? 'prev' : 'next';
     90                LHR.show_details(action);
     91                return;
     92            }
     93
     94            $('.media-modal').removeClass('open');
     95            $('.media-modal-backdrop').removeClass('open');
     96            $(document).off('keydown.lhr-modal-close');
     97        });
     98
     99        $(document).keydown(function(e) {
     100
     101            if (! $('.media-modal').hasClass('open')) {
     102                return;
     103            }
     104
     105            if (-1 < $.inArray(e.keyCode, [27, 38, 40])) {
     106                e.preventDefault();
     107
     108                if (27 == e.keyCode) { // esc
     109                    $('.media-modal-close').click();
     110                }
     111                else if (38 == e.keyCode) { // up
     112                    $('.media-modal-close.prev').click();
     113                }
     114                else if (40 == e.keyCode) { // down
     115                    $('.media-modal-close.next').click();
     116                }
     117            }
    70118        });
    71119
  • log-http-requests/trunk/includes/class-query.php

    r1698896 r2286528  
    5252
    5353        foreach ( $results as $row ) {
     54            $row['status_code'] = '-';
     55            $response = json_decode( $row['response'], true );
     56            if ( ! empty( $response['response']['code'] ) ) {
     57                $row['status_code'] = (int) $response['response']['code'];
     58            }
    5459            $row['runtime'] = round( $row['runtime'], 4 );
     60            $row['date_raw'] = $row['date_added'];
    5561            $row['date_added'] = LHR()->time_since( $row['date_added'] );
    5662            $output[] = $row;
  • log-http-requests/trunk/log-http-requests.php

    r2209242 r2286528  
    33Plugin Name: Log HTTP Requests
    44Description: Log all those pesky WP HTTP requests
    5 Version: 1.1
     5Version: 1.2
    66Author: FacetWP, LLC
    77Author URI: https://facetwp.com/
     
    3535
    3636        // setup variables
    37         define( 'LHR_VERSION', '1.1' );
     37        define( 'LHR_VERSION', '1.2' );
    3838        define( 'LHR_DIR', dirname( __FILE__ ) );
    3939        define( 'LHR_URL', plugins_url( '', __FILE__ ) );
     
    8383
    8484    function admin_menu() {
    85         add_options_page( 'Log HTTP Requests', 'Log HTTP Requests', 'manage_options', 'log-http-requests', array( $this, 'settings_page' ) );
     85        add_management_page( 'Log HTTP Requests', 'Log HTTP Requests', 'manage_options', 'log-http-requests', array( $this, 'settings_page' ) );
    8686    }
    8787
     
    9393
    9494    function admin_scripts( $hook ) {
    95         if ( 'settings_page_log-http-requests' == $hook ) {
     95        if ( 'tools_page_log-http-requests' == $hook ) {
    9696            wp_enqueue_script( 'lhr', LHR_URL . '/assets/js/admin.js', array( 'jquery' ) );
    9797            wp_enqueue_style( 'lhr', LHR_URL . '/assets/css/admin.css' );
  • log-http-requests/trunk/readme.txt

    r2209260 r2286528  
    33Tags: log, wp_http, requests, update checks, api
    44Requires at least: 4.9
    5 Tested up to: 5.3
     5Tested up to: 5.4
    66Stable tag: trunk
    77License: GPLv2
     
    4545
    46461. Download and activate the plugin.
    47 2. Browse to the `Log HTTP Requests` menu to view log entries.
     472. Browse to `Tools > Log HTTP Requests` to view log entries.
    4848
    4949== Changelog ==
     50
     51= 1.2 =
     52* Moved "Log HTTP Requests" to the `Tools` menu (props @aaemnnosttv)
     53* Added "Status" column to show HTTP response code (props @danielbachhuber)
     54* Added prev/next browsing to the detail modal (props @marcissimus)
     55* Added keyboard support (up, down, esc) to the detail modal (props @marcissimus)
     56* Added raw timestamp to "Date Added" column on hover
     57* Added hook docs to the readme
    5058
    5159= 1.1 =
  • log-http-requests/trunk/templates/page-settings.php

    r1866016 r2286528  
    2121            <tr>
    2222                <td>URL</td>
    23                 <td>Runtime (sec)</td>
     23                <td title="HTTP response code">Status</td>
     24                <td title="seconds">Runtime</td>
    2425                <td>Date Added</td>
    2526            </tr>
     
    3334
    3435<div class="media-modal">
     36    <button class="button-link media-modal-close prev"><span class="media-modal-icon"></span></button>
     37    <button class="button-link media-modal-close next"><span class="media-modal-icon"></span></button>
    3538    <button class="button-link media-modal-close"><span class="media-modal-icon"></span></button>
    3639    <div class="media-modal-content">
     
    4144            <div class="media-frame-content">
    4245                <div class="modal-content-wrap">
     46                    <h3>URL</h3>
     47                    <div>
     48                        [<span class="http-request-id"></span>]
     49                        <span class="http-url"></span>
     50                    </div>
    4351                    <div class="wrapper">
    4452                        <div class="box">
Note: See TracChangeset for help on using the changeset viewer.