82 * Filesystem credentials to be packaged along with the request. |
80 * Filesystem credentials to be packaged along with the request. |
83 * |
81 * |
84 * @since 4.2.0 |
82 * @since 4.2.0 |
85 * @since 4.6.0 Added `available` property to indicate whether credentials have been provided. |
83 * @since 4.6.0 Added `available` property to indicate whether credentials have been provided. |
86 * |
84 * |
87 * @type {object} filesystemCredentials Holds filesystem credentials. |
85 * @type {Object} |
88 * @type {object} filesystemCredentials.ftp Holds FTP credentials. |
86 * @property {Object} filesystemCredentials.ftp Holds FTP credentials. |
89 * @type {string} filesystemCredentials.ftp.host FTP host. Default empty string. |
87 * @property {string} filesystemCredentials.ftp.host FTP host. Default empty string. |
90 * @type {string} filesystemCredentials.ftp.username FTP user name. Default empty string. |
88 * @property {string} filesystemCredentials.ftp.username FTP user name. Default empty string. |
91 * @type {string} filesystemCredentials.ftp.password FTP password. Default empty string. |
89 * @property {string} filesystemCredentials.ftp.password FTP password. Default empty string. |
92 * @type {string} filesystemCredentials.ftp.connectionType Type of FTP connection. 'ssh', 'ftp', or 'ftps'. |
90 * @property {string} filesystemCredentials.ftp.connectionType Type of FTP connection. 'ssh', 'ftp', or 'ftps'. |
93 * Default empty string. |
91 * Default empty string. |
94 * @type {object} filesystemCredentials.ssh Holds SSH credentials. |
92 * @property {Object} filesystemCredentials.ssh Holds SSH credentials. |
95 * @type {string} filesystemCredentials.ssh.publicKey The public key. Default empty string. |
93 * @property {string} filesystemCredentials.ssh.publicKey The public key. Default empty string. |
96 * @type {string} filesystemCredentials.ssh.privateKey The private key. Default empty string. |
94 * @property {string} filesystemCredentials.ssh.privateKey The private key. Default empty string. |
97 * @type {string} filesystemCredentials.fsNonce Filesystem credentials form nonce. |
95 * @property {string} filesystemCredentials.fsNonce Filesystem credentials form nonce. |
98 * @type {bool} filesystemCredentials.available Whether filesystem credentials have been provided. |
96 * @property {bool} filesystemCredentials.available Whether filesystem credentials have been provided. |
99 * Default 'false'. |
97 * Default 'false'. |
100 */ |
98 */ |
101 wp.updates.filesystemCredentials = { |
99 wp.updates.filesystemCredentials = { |
102 ftp: { |
100 ftp: { |
103 host: '', |
101 host: '', |
104 username: '', |
102 username: '', |
168 * @param {number=} data.errors Optional. The amount of failed operations. |
166 * @param {number=} data.errors Optional. The amount of failed operations. |
169 * @param {Array=} data.errorMessages Optional. Error messages of failed operations. |
167 * @param {Array=} data.errorMessages Optional. Error messages of failed operations. |
170 * |
168 * |
171 */ |
169 */ |
172 wp.updates.addAdminNotice = function( data ) { |
170 wp.updates.addAdminNotice = function( data ) { |
173 var $notice = $( data.selector ), $adminNotice; |
171 var $notice = $( data.selector ), |
|
172 $headerEnd = $( '.wp-header-end' ), |
|
173 $adminNotice; |
174 |
174 |
175 delete data.selector; |
175 delete data.selector; |
176 $adminNotice = wp.updates.adminNotice( data ); |
176 $adminNotice = wp.updates.adminNotice( data ); |
177 |
177 |
178 // Check if this admin notice already exists. |
178 // Check if this admin notice already exists. |
405 * Updates the UI appropriately after a successful plugin update. |
408 * Updates the UI appropriately after a successful plugin update. |
406 * |
409 * |
407 * @since 4.2.0 |
410 * @since 4.2.0 |
408 * @since 4.6.0 More accurately named `updatePluginSuccess`. |
411 * @since 4.6.0 More accurately named `updatePluginSuccess`. |
409 * |
412 * |
410 * @typedef {object} updatePluginSuccess |
|
411 * @param {object} response Response from the server. |
413 * @param {object} response Response from the server. |
412 * @param {string} response.slug Slug of the plugin to be updated. |
414 * @param {string} response.slug Slug of the plugin to be updated. |
413 * @param {string} response.plugin Basename of the plugin to be updated. |
415 * @param {string} response.plugin Basename of the plugin to be updated. |
414 * @param {string} response.pluginName Name of the plugin to be updated. |
416 * @param {string} response.pluginName Name of the plugin to be updated. |
415 * @param {string} response.oldVersion Old version of the plugin. |
417 * @param {string} response.oldVersion Old version of the plugin. |
450 * Updates the UI appropriately after a failed plugin update. |
452 * Updates the UI appropriately after a failed plugin update. |
451 * |
453 * |
452 * @since 4.2.0 |
454 * @since 4.2.0 |
453 * @since 4.6.0 More accurately named `updatePluginError`. |
455 * @since 4.6.0 More accurately named `updatePluginError`. |
454 * |
456 * |
455 * @typedef {object} updatePluginError |
|
456 * @param {object} response Response from the server. |
457 * @param {object} response Response from the server. |
457 * @param {string} response.slug Slug of the plugin to be updated. |
458 * @param {string} response.slug Slug of the plugin to be updated. |
458 * @param {string} response.plugin Basename of the plugin to be updated. |
459 * @param {string} response.plugin Basename of the plugin to be updated. |
459 * @param {string=} response.pluginName Optional. Name of the plugin to be updated. |
460 * @param {string=} response.pluginName Optional. Name of the plugin to be updated. |
460 * @param {string} response.errorCode Error code for the error that occurred. |
461 * @param {string} response.errorCode Error code for the error that occurred. |
572 /** |
573 /** |
573 * Updates the UI appropriately after a successful plugin install. |
574 * Updates the UI appropriately after a successful plugin install. |
574 * |
575 * |
575 * @since 4.6.0 |
576 * @since 4.6.0 |
576 * |
577 * |
577 * @typedef {object} installPluginSuccess |
|
578 * @param {object} response Response from the server. |
578 * @param {object} response Response from the server. |
579 * @param {string} response.slug Slug of the installed plugin. |
579 * @param {string} response.slug Slug of the installed plugin. |
580 * @param {string} response.pluginName Name of the installed plugin. |
580 * @param {string} response.pluginName Name of the installed plugin. |
581 * @param {string} response.activateUrl URL to activate the just installed plugin. |
581 * @param {string} response.activateUrl URL to activate the just installed plugin. |
582 */ |
582 */ |
583 wp.updates.installPluginSuccess = function( response ) { |
583 wp.updates.installPluginSuccess = function( response ) { |
584 var $message = $( '.plugin-card-' + response.slug ).find( '.install-now' ); |
584 var $message = $( '.plugin-card-' + response.slug ).find( '.install-now' ); |
585 |
585 |
586 $message |
586 $message |
587 .removeClass( 'updating-message' ) |
587 .removeClass( 'updating-message' ) |
588 .addClass( 'updated-message installed' ) |
588 .addClass( 'updated-message installed button-disabled' ) |
589 .attr( 'aria-label', wp.updates.l10n.pluginInstalledLabel.replace( '%s', response.pluginName ) ) |
589 .attr( 'aria-label', wp.updates.l10n.pluginInstalledLabel.replace( '%s', response.pluginName ) ) |
590 .text( wp.updates.l10n.pluginInstalled ); |
590 .text( wp.updates.l10n.pluginInstalled ); |
591 |
591 |
592 if ( $message.hasClass( 'button-primary' ) ) { |
|
593 $message.addClass( 'button-primary-disabled' ); |
|
594 } else { |
|
595 $message.addClass( 'button-disabled' ); |
|
596 } |
|
597 |
|
598 wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' ); |
592 wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' ); |
599 |
593 |
600 $document.trigger( 'wp-plugin-install-success', response ); |
594 $document.trigger( 'wp-plugin-install-success', response ); |
601 |
595 |
602 if ( response.activateUrl ) { |
596 if ( response.activateUrl ) { |
603 setTimeout( function() { |
597 setTimeout( function() { |
604 |
598 |
605 // Transform the 'Install' button into an 'Activate' button. |
599 // Transform the 'Install' button into an 'Activate' button. |
606 $message.removeClass( 'install-now installed button-primary-disabled button-secondary-disabled button-disabled updated-message' ) |
600 $message.removeClass( 'install-now installed button-disabled updated-message' ).addClass( 'activate-now button-primary' ) |
607 .addClass( 'activate-now' ) |
|
608 .attr( 'href', response.activateUrl ) |
601 .attr( 'href', response.activateUrl ) |
609 .attr( 'aria-label', wp.updates.l10n.activatePluginLabel.replace( '%s', response.pluginName ) ) |
602 .attr( 'aria-label', wp.updates.l10n.activatePluginLabel.replace( '%s', response.pluginName ) ) |
610 .text( response.activateLabel || wp.updates.l10n.activatePlugin ); |
603 .text( wp.updates.l10n.activatePlugin ); |
611 }, 1000 ); |
604 }, 1000 ); |
612 } |
605 } |
613 }; |
606 }; |
614 |
607 |
615 /** |
608 /** |
616 * Updates the UI appropriately after a failed plugin install. |
609 * Updates the UI appropriately after a failed plugin install. |
617 * |
610 * |
618 * @since 4.6.0 |
611 * @since 4.6.0 |
619 * |
612 * |
620 * @typedef {object} installPluginError |
|
621 * @param {object} response Response from the server. |
613 * @param {object} response Response from the server. |
622 * @param {string} response.slug Slug of the plugin to be installed. |
614 * @param {string} response.slug Slug of the plugin to be installed. |
623 * @param {string=} response.pluginName Optional. Name of the plugin to be installed. |
615 * @param {string=} response.pluginName Optional. Name of the plugin to be installed. |
624 * @param {string} response.errorCode Error code for the error that occurred. |
616 * @param {string} response.errorCode Error code for the error that occurred. |
625 * @param {string} response.errorMessage The error that occurred. |
617 * @param {string} response.errorMessage The error that occurred. |
698 /** |
689 /** |
699 * Updates the UI appropriately after a failed importer install. |
690 * Updates the UI appropriately after a failed importer install. |
700 * |
691 * |
701 * @since 4.6.0 |
692 * @since 4.6.0 |
702 * |
693 * |
703 * @typedef {object} installImporterError |
|
704 * @param {object} response Response from the server. |
694 * @param {object} response Response from the server. |
705 * @param {string} response.slug Slug of the plugin to be installed. |
695 * @param {string} response.slug Slug of the plugin to be installed. |
706 * @param {string=} response.pluginName Optional. Name of the plugin to be installed. |
696 * @param {string=} response.pluginName Optional. Name of the plugin to be installed. |
707 * @param {string} response.errorCode Error code for the error that occurred. |
697 * @param {string} response.errorCode Error code for the error that occurred. |
708 * @param {string} response.errorMessage The error that occurred. |
698 * @param {string} response.errorMessage The error that occurred. |
773 /** |
763 /** |
774 * Updates the UI appropriately after a successful plugin deletion. |
764 * Updates the UI appropriately after a successful plugin deletion. |
775 * |
765 * |
776 * @since 4.6.0 |
766 * @since 4.6.0 |
777 * |
767 * |
778 * @typedef {object} deletePluginSuccess |
768 * @param {Object} response Response from the server. |
779 * @param {object} response Response from the server. |
|
780 * @param {string} response.slug Slug of the plugin that was deleted. |
769 * @param {string} response.slug Slug of the plugin that was deleted. |
781 * @param {string} response.plugin Base name of the plugin that was deleted. |
770 * @param {string} response.plugin Base name of the plugin that was deleted. |
782 * @param {string} response.pluginName Name of the plugin that was deleted. |
771 * @param {string} response.pluginName Name of the plugin that was deleted. |
783 */ |
772 */ |
784 wp.updates.deletePluginSuccess = function( response ) { |
773 wp.updates.deletePluginSuccess = function( response ) { |
788 var $form = $( '#bulk-action-form' ), |
777 var $form = $( '#bulk-action-form' ), |
789 $views = $( '.subsubsub' ), |
778 $views = $( '.subsubsub' ), |
790 $pluginRow = $( this ), |
779 $pluginRow = $( this ), |
791 columnCount = $form.find( 'thead th:not(.hidden), thead td' ).length, |
780 columnCount = $form.find( 'thead th:not(.hidden), thead td' ).length, |
792 pluginDeletedRow = wp.template( 'item-deleted-row' ), |
781 pluginDeletedRow = wp.template( 'item-deleted-row' ), |
793 /** @type {object} plugins Base names of plugins in their different states. */ |
782 /** |
|
783 * Plugins Base names of plugins in their different states. |
|
784 * |
|
785 * @type {Object} |
|
786 */ |
794 plugins = settings.plugins; |
787 plugins = settings.plugins; |
795 |
788 |
796 // Add a success message after deleting a plugin. |
789 // Add a success message after deleting a plugin. |
797 if ( ! $pluginRow.hasClass( 'plugin-update-tr' ) ) { |
790 if ( ! $pluginRow.hasClass( 'plugin-update-tr' ) ) { |
798 $pluginRow.after( |
791 $pluginRow.after( |
863 /** |
856 /** |
864 * Updates the UI appropriately after a failed plugin deletion. |
857 * Updates the UI appropriately after a failed plugin deletion. |
865 * |
858 * |
866 * @since 4.6.0 |
859 * @since 4.6.0 |
867 * |
860 * |
868 * @typedef {object} deletePluginError |
|
869 * @param {object} response Response from the server. |
861 * @param {object} response Response from the server. |
870 * @param {string} response.slug Slug of the plugin to be deleted. |
862 * @param {string} response.slug Slug of the plugin to be deleted. |
871 * @param {string} response.plugin Base name of the plugin to be deleted |
863 * @param {string} response.plugin Base name of the plugin to be deleted |
872 * @param {string=} response.pluginName Optional. Name of the plugin to be deleted. |
864 * @param {string=} response.pluginName Optional. Name of the plugin to be deleted. |
873 * @param {string} response.errorCode Error code for the error that occurred. |
865 * @param {string} response.errorCode Error code for the error that occurred. |
1606 /** |
1592 /** |
1607 * Handles credentials errors if it could not connect to the filesystem. |
1593 * Handles credentials errors if it could not connect to the filesystem. |
1608 * |
1594 * |
1609 * @since 4.6.0 |
1595 * @since 4.6.0 |
1610 * |
1596 * |
1611 * @typedef {object} maybeHandleCredentialError |
|
1612 * @param {object} response Response from the server. |
1597 * @param {object} response Response from the server. |
1613 * @param {string} response.errorCode Error code for the error that occurred. |
1598 * @param {string} response.errorCode Error code for the error that occurred. |
1614 * @param {string} response.errorMessage The error that occurred. |
1599 * @param {string} response.errorMessage The error that occurred. |
1615 * @param {string} action The type of request to perform. |
1600 * @param {string} action The type of request to perform. |
1616 * @returns {boolean} Whether there is an error that needs to be handled or not. |
1601 * @returns {boolean} Whether there is an error that needs to be handled or not. |
2337 event.preventDefault(); |
2322 event.preventDefault(); |
2338 |
2323 |
2339 $( 'input.wp-filter-search' ).trigger( 'input' ); |
2324 $( 'input.wp-filter-search' ).trigger( 'input' ); |
2340 } ); |
2325 } ); |
2341 |
2326 |
2342 /** |
2327 /** |
2343 * Trigger a search event when the "Try Again" button is clicked. |
2328 * Trigger a search event when the "Try Again" button is clicked. |
2344 * |
2329 * |
2345 * @since 4.9.0 |
2330 * @since 4.9.0 |
2346 */ |
2331 */ |
2347 $document.on( 'click', '.try-again', function( event ) { |
2332 $document.on( 'click', '.try-again', function( event ) { |
2348 event.preventDefault(); |
2333 event.preventDefault(); |
2349 $pluginInstallSearch.trigger( 'input' ); |
2334 $pluginInstallSearch.trigger( 'input' ); |
2350 } ); |
2335 } ); |
2351 |
2336 |
2352 /** |
2337 /** |
2353 * Trigger a search event when the search type gets changed. |
2338 * Trigger a search event when the search type gets changed. |
2354 * |
2339 * |