Ticket #50145: 50145.diff
| File 50145.diff, 3.0 KB (added by , 6 years ago) |
|---|
-
src/js/_enqueues/admin/site-health.js
65 65 goodIssuesWrapper.toggleClass( 'hidden' ); 66 66 $( this ).attr( 'aria-expanded', ! goodIssuesWrapper.hasClass( 'hidden' ) ); 67 67 } ); 68 69 /* 70 * Object.entries polyfill. 71 * 72 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries 73 */ 74 if ( ! Object.entries ) { 75 Object.entries = function( obj ) { 76 var ownProps = Object.keys( obj ), 77 ownValues = Object.values( obj ), 78 i = ownProps.length, 79 resArray = new Array( i ); // Preallocate the array. 68 80 81 while ( i-- ) { 82 resArray[ i ] = [ ownProps[ i ], ownValues[ i ] ]; 83 } 84 85 return resArray; 86 }; 87 } 88 69 89 /** 90 * Validates the Site Health test result format. 91 * 92 * @since 5.5.0 93 * 94 * @param {Object} issue 95 * 96 * @return {boolean} 97 */ 98 function validateIssueData( issue ) { 99 // Expected minimum format of a valid SiteHealth test response. 100 var minimumExpected = { 101 test: 'string', 102 label: 'string', 103 description: 'string' 104 }; 105 var passed = true; 106 107 // Loop over expected data and match the data types. 108 Object.entries( minimumExpected ).forEach( ( [ key, value ] ) => { 109 if ( 'object' === typeof( value ) ) { 110 Object.entries( value ).forEach( ( [ subKey, subValue ] ) => { 111 if ( 112 'undefined' === typeof( issue[ key ] ) || 113 'undefined' === typeof( issue[ key ][ subKey ] ) || 114 subValue !== typeof( issue[ key ][ subKey ] ) 115 ) { 116 passed = false; 117 } 118 } ); 119 } else { 120 if ( 121 'undefined' === typeof( issue[ key ] ) || 122 value !== typeof( issue[ key ] ) 123 ) { 124 passed = false; 125 } 126 } 127 } ); 128 129 return passed; 130 } 131 132 /** 70 133 * Appends a new issue to the issue list. 71 134 * 72 135 * @since 5.2.0 … … 79 142 heading, 80 143 count; 81 144 145 /* 146 * Validate the issue data format before using it. 147 * If the output is invalid, discard it. 148 */ 149 if ( ! validateIssueData( issue ) ) { 150 return false; 151 } 152 82 153 SiteHealth.site_status.issues[ issue.status ]++; 83 154 84 155 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)