Changeset 2286528
- Timestamp:
- 04/18/2020 08:07:46 PM (6 years ago)
- Location:
- log-http-requests/trunk
- Files:
-
- 6 edited
-
assets/css/admin.css (modified) (4 diffs)
-
assets/js/admin.js (modified) (3 diffs)
-
includes/class-query.php (modified) (1 diff)
-
log-http-requests.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
-
templates/page-settings.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
log-http-requests/trunk/assets/css/admin.css
r2022732 r2286528 9 9 } 10 10 11 .widefat .field-status-code, 11 12 .widefat .field-runtime, 12 13 .widefat .field-date { … … 33 34 .http-request-args, 34 35 .http-response { 35 max-height: 3 60px;36 max-height: 300px; 36 37 font-family: monospace; 37 38 white-space: pre; … … 73 74 } 74 75 76 .media-modal.open, 77 .media-modal-backdrop.open { 78 display: block; 79 } 80 75 81 .media-frame-title, 76 82 .media-frame-content { … … 93 99 } 94 100 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 95 117 .modal-content-wrap { 96 118 padding: 16px; -
log-http-requests/trunk/assets/js/admin.js
r1698896 r2286528 24 24 <div><a href="javascript:;" data-id="` + idx + `">` + row.url + `</a></div> 25 25 </td> 26 <td class="field-status-code">` + row.status_code + `</td> 26 27 <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> 28 29 </tr> 29 30 `; … … 48 49 } 49 50 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 50 72 // Page change 51 73 $(document).on('click', '.lhr-page:not(.active)', function() { … … 56 78 // Open detail modal 57 79 $(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'); 64 82 }); 65 83 66 84 // Close modal window 67 85 $(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 } 70 118 }); 71 119 -
log-http-requests/trunk/includes/class-query.php
r1698896 r2286528 52 52 53 53 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 } 54 59 $row['runtime'] = round( $row['runtime'], 4 ); 60 $row['date_raw'] = $row['date_added']; 55 61 $row['date_added'] = LHR()->time_since( $row['date_added'] ); 56 62 $output[] = $row; -
log-http-requests/trunk/log-http-requests.php
r2209242 r2286528 3 3 Plugin Name: Log HTTP Requests 4 4 Description: Log all those pesky WP HTTP requests 5 Version: 1. 15 Version: 1.2 6 6 Author: FacetWP, LLC 7 7 Author URI: https://facetwp.com/ … … 35 35 36 36 // setup variables 37 define( 'LHR_VERSION', '1. 1' );37 define( 'LHR_VERSION', '1.2' ); 38 38 define( 'LHR_DIR', dirname( __FILE__ ) ); 39 39 define( 'LHR_URL', plugins_url( '', __FILE__ ) ); … … 83 83 84 84 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' ) ); 86 86 } 87 87 … … 93 93 94 94 function admin_scripts( $hook ) { 95 if ( ' settings_page_log-http-requests' == $hook ) {95 if ( 'tools_page_log-http-requests' == $hook ) { 96 96 wp_enqueue_script( 'lhr', LHR_URL . '/assets/js/admin.js', array( 'jquery' ) ); 97 97 wp_enqueue_style( 'lhr', LHR_URL . '/assets/css/admin.css' ); -
log-http-requests/trunk/readme.txt
r2209260 r2286528 3 3 Tags: log, wp_http, requests, update checks, api 4 4 Requires at least: 4.9 5 Tested up to: 5. 35 Tested up to: 5.4 6 6 Stable tag: trunk 7 7 License: GPLv2 … … 45 45 46 46 1. Download and activate the plugin. 47 2. Browse to the `Log HTTP Requests` menuto view log entries.47 2. Browse to `Tools > Log HTTP Requests` to view log entries. 48 48 49 49 == 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 50 58 51 59 = 1.1 = -
log-http-requests/trunk/templates/page-settings.php
r1866016 r2286528 21 21 <tr> 22 22 <td>URL</td> 23 <td>Runtime (sec)</td> 23 <td title="HTTP response code">Status</td> 24 <td title="seconds">Runtime</td> 24 25 <td>Date Added</td> 25 26 </tr> … … 33 34 34 35 <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> 35 38 <button class="button-link media-modal-close"><span class="media-modal-icon"></span></button> 36 39 <div class="media-modal-content"> … … 41 44 <div class="media-frame-content"> 42 45 <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> 43 51 <div class="wrapper"> 44 52 <div class="box">
Note: See TracChangeset
for help on using the changeset viewer.