Ticket #50145: 50145.2.patch
| File 50145.2.patch, 2.7 KB (added by , 6 years ago) |
|---|
-
src/js/_enqueues/admin/site-health.js
66 66 $( this ).attr( 'aria-expanded', ! goodIssuesWrapper.hasClass( 'hidden' ) ); 67 67 } ); 68 68 69 /** 70 * Validates the Site Health test result format. 71 * 72 * @since 5.6.0 73 * 74 * @param {Object} issue 75 * 76 * @return {boolean} 77 */ 78 function validateIssueData( issue ) { 79 // Expected minimum format of a valid SiteHealth test response. 80 var minimumExpected = { 81 test: 'string', 82 label: 'string', 83 description: 'string' 84 }; 85 var passed = true; 86 87 // If the issue passed is not an object, return a `false` state early. 88 if ( 'object' !== typeof( issue ) ) { 89 return false; 90 } 91 92 // Loop over expected data and match the data types. 93 for ( var key in minimumExpected ) { 94 var value = minimumExpected[ key ]; 95 96 if ( 'object' === typeof( value ) ) { 97 for ( var subKey in value ) { 98 var subValue = value[ subKey ]; 99 100 if ( 101 'undefined' === typeof( issue[ key ] ) || 102 'undefined' === typeof( issue[ key ][ subKey ] ) || 103 subValue !== typeof( issue[ key ][ subKey ] ) 104 ) { 105 passed = false; 106 } 107 } 108 } else { 109 if ( 110 'undefined' === typeof( issue[ key ] ) || 111 value !== typeof( issue[ key ] ) 112 ) { 113 passed = false; 114 } 115 } 116 } 117 118 return passed; 119 } 120 69 121 /** 70 122 * Appends a new issue to the issue list. 71 123 * … … 78 130 issueWrapper = $( '#health-check-issues-' + issue.status ), 79 131 heading, 80 132 count; 81 133 134 /* 135 * Validate the issue data format before using it. 136 * If the output is invalid, discard it. 137 */ 138 if ( ! validateIssueData( issue ) ) { 139 return false; 140 } 141 82 142 SiteHealth.site_status.issues[ issue.status ]++; 83 143 84 144 count = SiteHealth.site_status.issues[ issue.status ]; -
src/wp-admin/site-health.php
144 144 <h4 class="health-check-accordion-heading"> 145 145 <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-{{ data.test }}" type="button"> 146 146 <span class="title">{{ data.label }}</span> 147 <span class="badge {{ data.badge.color }}">{{ data.badge.label }}</span> 147 <# if ( data.badge ) { #> 148 <span class="badge {{ data.badge.color }}">{{ data.badge.label }}</span> 149 <# } #> 148 150 <span class="icon"></span> 149 151 </button> 150 152 </h4>
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)