Skip to content
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d98b9f1
Add GitHub Actions workflows for everything currently handled in Trav…
desrosj Oct 12, 2020
6e546ab
Indicate that JS standards are also checked in this workflow.
desrosj Oct 12, 2020
d10a9a9
Continuing to refine:
desrosj Oct 13, 2020
bb92995
Be more explicit within `on` and use human readable part of `check_na…
desrosj Oct 13, 2020
690dc97
Merge branch 'master' into trac/50401-add-github-actions
desrosj Oct 14, 2020
c8d9481
Admin Menu: Better wrapping for long menu item names.
helen Oct 14, 2020
e72f248
Merge updates.
desrosj Oct 14, 2020
0aa3ade
Updates: Reduce secondary buttons for less visual complexity.
helen Oct 14, 2020
d0ec93f
I18N: Use `wp.i18n` for translatable strings in `wp-admin/js/dashboar…
ocean90 Oct 14, 2020
52f2d0d
Community Events: Update timezone-related `@since` tags to `5.5.2`.
iandunn Oct 14, 2020
50fa352
Docs: Improve description of the `$email` parameter in `email_exists()`.
SergeyBiryukov Oct 15, 2020
efe06cd
Site Health, REST API: Move async tests to REST API endpoints.
TimothyBJacobs Oct 15, 2020
73fb2c1
REST API: Grant super admin to site health test user.
TimothyBJacobs Oct 15, 2020
701dee2
REST API: Exclude custom site health capability check on multisite.
TimothyBJacobs Oct 15, 2020
46a598a
Limit push runs to master and version branches.
desrosj Oct 15, 2020
ed611d8
Limit when actions run.
desrosj Oct 15, 2020
8e53b26
Improve language of welcome message.
desrosj Oct 15, 2020
c978c99
Let's stay on PHP 7.4 for PHPCS testing until we verify our tooling i…
desrosj Oct 15, 2020
2092637
Node needs to be installed before caching.
desrosj Oct 15, 2020
277c3eb
Make the version of Node dynamic based on the `.nvmrc` file.
desrosj Oct 15, 2020
7b73653
Detect the desired NodeJS version dynamically.
desrosj Oct 15, 2020
d009960
`actions/setup-node` does not currently support aliases like LTS
desrosj Oct 15, 2020
b0c0739
Remove stray nvmrc reference.
desrosj Oct 15, 2020
8bf847b
Comments: Remove extra space from the comment link in `Walker_Comment`.
SergeyBiryukov Oct 15, 2020
7bfe507
Twenty Twenty: Remove extra space from the comment link in `TwentyTwe…
SergeyBiryukov Oct 15, 2020
fee906a
Twenty Nineteen: Remove extra space from the comment link in `TwentyN…
SergeyBiryukov Oct 15, 2020
c0f41b5
Comments: Further remove unnecessary context switch in `Walker_Comment`.
SergeyBiryukov Oct 15, 2020
ec260b0
Merge branch 'master' into trac/50401-add-github-actions
desrosj Oct 15, 2020
f138386
Introduce a jshint warning.
desrosj Oct 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions src/js/_enqueues/admin/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ function deprecatedProperty( propName, version, replacement ) {
* Deprecate all properties on an object.
*
* @since 5.5.1
* @since 5.6.0 Added the `version` parameter.
*
* @param {string} name The name of the object, i.e. commonL10n.
* @param {object} l10nObject The object to deprecate the properties on.
* @param {string} version The version of WordPress that deprecated the property.
*
* @return {object} The object with all its properties deprecated.
*/
function deprecateL10nObject( name, l10nObject ) {
function deprecateL10nObject( name, l10nObject, version ) {
var deprecatedObject = {};

Object.keys( l10nObject ).forEach( function( key ) {
Expand All @@ -70,12 +72,12 @@ function deprecateL10nObject( name, l10nObject ) {

if ( 'object' === typeof prop ) {
Object.defineProperty( deprecatedObject, key, { get: function() {
deprecatedProperty( propName, '5.5.0', prop.alternative );
deprecatedProperty( propName, version, prop.alternative );
return prop.func();
} } );
} else {
Object.defineProperty( deprecatedObject, key, { get: function() {
deprecatedProperty( propName, '5.5.0', 'wp.i18n' );
deprecatedProperty( propName, version, 'wp.i18n' );
return prop;
} } );
}
Expand All @@ -99,7 +101,7 @@ window.commonL10n = window.commonL10n || {
expandMenu: ''
};

window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n );
window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -111,7 +113,7 @@ window.wpPointerL10n = window.wpPointerL10n || {
dismiss: ''
};

window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n );
window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -129,7 +131,7 @@ window.userProfileL10n = window.userProfileL10n || {
ariaHide: ''
};

window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n );
window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -148,7 +150,7 @@ window.privacyToolsL10n = window.privacyToolsL10n || {
exportError: ''
};

window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n );
window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -160,7 +162,7 @@ window.authcheckL10n = {
beforeunload: ''
};

window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n );
window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -173,7 +175,7 @@ window.tagsl10n = {
broken: ''
};

window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n );
window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -198,7 +200,7 @@ window.adminCommentsL10n = window.adminCommentsL10n || {
docTitleCommentsCount: ''
};

window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n );
window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -214,7 +216,7 @@ window.tagsSuggestL10n = window.tagsSuggestL10n || {
termRemoved: ''
};

window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n );
window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -231,7 +233,7 @@ window.wpColorPickerL10n = window.wpColorPickerL10n || {
defaultLabel: ''
};

window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n );
window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -243,7 +245,7 @@ window.attachMediaBoxL10n = window.attachMediaBoxL10n || {
error: ''
};

window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n );
window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand Down Expand Up @@ -276,7 +278,7 @@ window.postL10n = window.postL10n || {
permalinkSaved: ''
};

window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n );
window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -292,7 +294,7 @@ window.inlineEditL10n = window.inlineEditL10n || {
saved: ''
};

window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n );
window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -306,7 +308,7 @@ window.plugininstallL10n = window.plugininstallL10n || {
ays: ''
};

window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n );
window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -321,7 +323,7 @@ window.navMenuL10n = window.navMenuL10n || {
untitled: ''
};

window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n );
window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -334,7 +336,7 @@ window.commentL10n = window.commentL10n || {
dateFormat: ''
};

window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n );
window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n, '5.5.0' );

/**
* Removed in 5.5.0, needed for back-compatibility.
Expand All @@ -349,7 +351,7 @@ window.setPostThumbnailL10n = window.setPostThumbnailL10n || {
done: ''
};

window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n );
window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n, '5.5.0' );

/**
* Removed in 3.3.0, needed for back-compatibility.
Expand Down
115 changes: 77 additions & 38 deletions src/js/_enqueues/admin/site-health.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jQuery( document ).ready( function( $ ) {
var __ = wp.i18n.__,
_n = wp.i18n._n,
sprintf = wp.i18n.sprintf,
data,
clipboard = new ClipboardJS( '.site-health-copy-buttons .copy-button' ),
isDebugTab = $( '.health-check-body.health-check-debug-tab' ).length,
pathsSizesSection = $( '#health-check-accordion-block-wp-paths-sizes' ),
Expand Down Expand Up @@ -78,11 +77,16 @@ jQuery( document ).ready( function( $ ) {
issueWrapper = $( '#health-check-issues-' + issue.status ),
heading,
count;

SiteHealth.site_status.issues[ issue.status ]++;

count = SiteHealth.site_status.issues[ issue.status ];

// If no test name is supplied, append a placeholder for markup references.
if ( typeof issue.test === 'undefined' ) {
issue.test = issue.status + count;
}

if ( 'critical' === issue.status ) {
heading = sprintf(
_n( '%s critical issue', '%s critical issues', count ),
Expand Down Expand Up @@ -119,10 +123,10 @@ jQuery( document ).ready( function( $ ) {
var $progressLabel = $( '.site-health-progress-label', $wrapper );
var $circle = $( '.site-health-progress svg #bar' );
var totalTests = parseInt( SiteHealth.site_status.issues.good, 0 ) +
parseInt( SiteHealth.site_status.issues.recommended, 0 ) +
( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 );
parseInt( SiteHealth.site_status.issues.recommended, 0 ) +
( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 );
var failedTests = ( parseInt( SiteHealth.site_status.issues.recommended, 0 ) * 0.5 ) +
( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 );
( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 );
var val = 100 - Math.ceil( ( failedTests / totalTests ) * 100 );

if ( 0 === totalTests ) {
Expand Down Expand Up @@ -206,15 +210,49 @@ jQuery( document ).ready( function( $ ) {

this.completed = true;

$.post(
ajaxurl,
data,
function( response ) {
if ( 'undefined' !== typeof( this.has_rest ) && this.has_rest ) {
wp.apiRequest( {
url: this.test
} )
.done( function( response ) {
/** This filter is documented in wp-admin/includes/class-wp-site-health.php */
appendIssue( wp.hooks.applyFilters( 'site_status_test_result', response ) );
} )
.fail( function( response ) {
var description;

if ( 'undefined' !== typeof( response.responseJSON ) && 'undefined' !== typeof( response.responseJSON.message ) ) {
description = response.responseJSON.message;
} else {
description = __( 'No details available' );
}

addFailedSiteHealthCheckNotice( this.url, description );
} )
.always( function() {
maybeRunNextAsyncTest();
} );
} else {
$.post(
ajaxurl,
data
).done( function( response ) {
/** This filter is documented in wp-admin/includes/class-wp-site-health.php */
appendIssue( wp.hooks.applyFilters( 'site_status_test_result', response.data ) );
} ).fail( function( response ) {
var description;

if ( 'undefined' !== typeof( response.responseJSON ) && 'undefined' !== typeof( response.responseJSON.message ) ) {
description = response.responseJSON.message;
} else {
description = __( 'No details available' );
}

addFailedSiteHealthCheckNotice( this.url, description );
} ).always( function() {
maybeRunNextAsyncTest();
}
);
} );
}

return false;
} );
Expand All @@ -225,6 +263,29 @@ jQuery( document ).ready( function( $ ) {
}
}

/**
* Add the details of a failed asynchronous test to the list of test results.
*
* @since 5.6.0
*/
function addFailedSiteHealthCheckNotice( url, description ) {
var issue;

issue = {
'status': 'recommended',
'label': __( 'A test is unavailable' ),
'badge': {
'color': 'red',
'label': __( 'Unavailable' )
},
'description': '<p>' + url + '</p><p>' + description + '</p>',
'actions': ''
};

/** This filter is documented in wp-admin/includes/class-wp-site-health.php */
appendIssue( wp.hooks.applyFilters( 'site_status_test_result', issue ) );
}

if ( 'undefined' !== typeof SiteHealth && ! isDebugTab ) {
if ( 0 === SiteHealth.site_status.direct.length && 0 === SiteHealth.site_status.async.length ) {
recalculateProgression();
Expand All @@ -243,53 +304,31 @@ jQuery( document ).ready( function( $ ) {
}

if ( 0 < SiteHealth.site_status.async.length ) {
data = {
'action': 'health-check-' + SiteHealth.site_status.async[0].test.replace( '_', '-' ),
'_wpnonce': SiteHealth.nonce.site_status
};

SiteHealth.site_status.async[0].completed = true;

$.post(
ajaxurl,
data,
function( response ) {
appendIssue( response.data );
maybeRunNextAsyncTest();
}
);
maybeRunNextAsyncTest();
} else {
recalculateProgression();
}
}

function getDirectorySizes() {
var data = {
action: 'health-check-get-sizes',
_wpnonce: SiteHealth.nonce.site_status_result
};

var timestamp = ( new Date().getTime() );

// After 3 seconds announce that we're still waiting for directory sizes.
var timeout = window.setTimeout( function() {
wp.a11y.speak( __( 'Please wait...' ) );
}, 3000 );

$.post( {
type: 'POST',
url: ajaxurl,
data: data,
dataType: 'json'
wp.apiRequest( {
path: '/wp-site-health/v1/directory-sizes'
} ).done( function( response ) {
updateDirSizes( response.data || {} );
updateDirSizes( response || {} );
} ).always( function() {
var delay = ( new Date().getTime() ) - timestamp;

$( '.health-check-wp-paths-sizes.spinner' ).css( 'visibility', 'hidden' );
recalculateProgression();

if ( delay > 3000 ) {
if ( delay > 3000 ) {
/*
* We have announced that we're waiting.
* Announce that we're ready after giving at least 3 seconds
Expand Down
2 changes: 1 addition & 1 deletion src/js/_enqueues/admin/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,4 +760,4 @@ wpWidgets.l10n = wpWidgets.l10n || {
widgetAdded: ''
};

wpWidgets.l10n = window.wp.deprecateL10nObject( 'wpWidgets.l10n', wpWidgets.l10n );
wpWidgets.l10n = window.wp.deprecateL10nObject( 'wpWidgets.l10n', wpWidgets.l10n, '5.5.0' );
Loading