wp/wp-admin/js/updates.js
author ymh <ymh.work@gmail.com>
Wed, 21 Sep 2022 18:19:35 +0200
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
permissions -rw-r--r--
Site enmi version 09/2022
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     1
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     2
 * Functions for ajaxified updates, deletions and installs inside the WordPress admin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     3
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     4
 * @version 4.2.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     5
 * @output wp-admin/js/updates.js
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     6
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     8
/* global pagenow */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    10
/**
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    11
 * @param {jQuery}  $                                        jQuery object.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    12
 * @param {object}  wp                                       WP object.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    13
 * @param {object}  settings                                 WP Updates settings.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    14
 * @param {string}  settings.ajax_nonce                      Ajax nonce.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    15
 * @param {object=} settings.plugins                         Base names of plugins in their different states.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    16
 * @param {Array}   settings.plugins.all                     Base names of all plugins.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    17
 * @param {Array}   settings.plugins.active                  Base names of active plugins.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    18
 * @param {Array}   settings.plugins.inactive                Base names of inactive plugins.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    19
 * @param {Array}   settings.plugins.upgrade                 Base names of plugins with updates available.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    20
 * @param {Array}   settings.plugins.recently_activated      Base names of recently activated plugins.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    21
 * @param {Array}   settings.plugins['auto-update-enabled']  Base names of plugins set to auto-update.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    22
 * @param {Array}   settings.plugins['auto-update-disabled'] Base names of plugins set to not auto-update.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    23
 * @param {object=} settings.themes                          Slugs of themes in their different states.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    24
 * @param {Array}   settings.themes.all                      Slugs of all themes.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    25
 * @param {Array}   settings.themes.upgrade                  Slugs of themes with updates available.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    26
 * @param {Arrat}   settings.themes.disabled                 Slugs of disabled themes.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    27
 * @param {Array}   settings.themes['auto-update-enabled']   Slugs of themes set to auto-update.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    28
 * @param {Array}   settings.themes['auto-update-disabled']  Slugs of themes set to not auto-update.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    29
 * @param {object=} settings.totals                          Combined information for available update counts.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    30
 * @param {number}  settings.totals.count                    Holds the amount of available updates.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    31
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    32
(function( $, wp, settings ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    33
	var $document = $( document ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    34
		__ = wp.i18n.__,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    35
		_x = wp.i18n._x,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    36
		sprintf = wp.i18n.sprintf;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    37
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    38
	wp = wp || {};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    39
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    40
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    41
	 * The WP Updates object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    42
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    43
	 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    44
	 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    45
	 * @namespace wp.updates
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    46
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
	wp.updates = {};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
	/**
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    50
	 * Removed in 5.5.0, needed for back-compatibility.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    51
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    52
	 * @since 4.2.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    53
	 * @deprecated 5.5.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    54
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    55
	 * @type {object}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    56
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    57
	wp.updates.l10n = {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    58
		searchResults: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    59
		searchResultsLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    60
		noPlugins: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    61
		noItemsSelected: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    62
		updating: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    63
		pluginUpdated: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    64
		themeUpdated: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    65
		update: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    66
		updateNow: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    67
		pluginUpdateNowLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    68
		updateFailedShort: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    69
		updateFailed: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    70
		pluginUpdatingLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    71
		pluginUpdatedLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    72
		pluginUpdateFailedLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    73
		updatingMsg: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    74
		updatedMsg: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    75
		updateCancel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    76
		beforeunload: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    77
		installNow: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    78
		pluginInstallNowLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    79
		installing: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    80
		pluginInstalled: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    81
		themeInstalled: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    82
		installFailedShort: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    83
		installFailed: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    84
		pluginInstallingLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    85
		themeInstallingLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    86
		pluginInstalledLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    87
		themeInstalledLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    88
		pluginInstallFailedLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    89
		themeInstallFailedLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    90
		installingMsg: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    91
		installedMsg: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    92
		importerInstalledMsg: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    93
		aysDelete: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    94
		aysDeleteUninstall: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    95
		aysBulkDelete: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    96
		aysBulkDeleteThemes: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    97
		deleting: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    98
		deleteFailed: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    99
		pluginDeleted: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   100
		themeDeleted: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   101
		livePreview: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   102
		activatePlugin: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   103
		activateTheme: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   104
		activatePluginLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   105
		activateThemeLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   106
		activateImporter: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   107
		activateImporterLabel: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   108
		unknownError: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   109
		connectionError: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   110
		nonceError: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   111
		pluginsFound: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   112
		noPluginsFound: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   113
		autoUpdatesEnable: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   114
		autoUpdatesEnabling: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   115
		autoUpdatesEnabled: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   116
		autoUpdatesDisable: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   117
		autoUpdatesDisabling: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   118
		autoUpdatesDisabled: '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   119
		autoUpdatesError: ''
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   120
	};
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   121
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   122
	wp.updates.l10n = window.wp.deprecateL10nObject( 'wp.updates.l10n', wp.updates.l10n, '5.5.0' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   123
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   124
	/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
	 * User nonce for ajax calls.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
	 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   129
	 * @type {string}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   131
	wp.updates.ajaxNonce = settings.ajax_nonce;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   134
	 * Current search term.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   135
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   136
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   137
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   138
	 * @type {string}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   139
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   140
	wp.updates.searchTerm = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
	 * Whether filesystem credentials need to be requested from the user.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
	 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   147
	 * @type {bool}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   149
	wp.updates.shouldRequestFilesystemCredentials = false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
	 * Filesystem credentials to be packaged along with the request.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
	 * @since 4.2.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   155
	 * @since 4.6.0 Added `available` property to indicate whether credentials have been provided.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
	 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   157
	 * @type {Object}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   158
	 * @property {Object} filesystemCredentials.ftp                Holds FTP credentials.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   159
	 * @property {string} filesystemCredentials.ftp.host           FTP host. Default empty string.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   160
	 * @property {string} filesystemCredentials.ftp.username       FTP user name. Default empty string.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   161
	 * @property {string} filesystemCredentials.ftp.password       FTP password. Default empty string.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   162
	 * @property {string} filesystemCredentials.ftp.connectionType Type of FTP connection. 'ssh', 'ftp', or 'ftps'.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   163
	 *                                                             Default empty string.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   164
	 * @property {Object} filesystemCredentials.ssh                Holds SSH credentials.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   165
	 * @property {string} filesystemCredentials.ssh.publicKey      The public key. Default empty string.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   166
	 * @property {string} filesystemCredentials.ssh.privateKey     The private key. Default empty string.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   167
	 * @property {string} filesystemCredentials.fsNonce            Filesystem credentials form nonce.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   168
	 * @property {bool}   filesystemCredentials.available          Whether filesystem credentials have been provided.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   169
	 *                                                             Default 'false'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
	wp.updates.filesystemCredentials = {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   172
		ftp:       {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   173
			host:           '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   174
			username:       '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   175
			password:       '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   176
			connectionType: ''
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
		},
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   178
		ssh:       {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   179
			publicKey:  '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   180
			privateKey: ''
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   181
		},
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   182
		fsNonce: '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   183
		available: false
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
	};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   187
	 * Whether we're waiting for an Ajax request to complete.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
	 * @since 4.2.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   190
	 * @since 4.6.0 More accurately named `ajaxLocked`.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   192
	 * @type {bool}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   194
	wp.updates.ajaxLocked = false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   197
	 * Admin notice template.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   199
	 * @since 4.6.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
	 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   201
	 * @type {function}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   203
	wp.updates.adminNotice = wp.template( 'wp-updates-admin-notice' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   206
	 * Update queue.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   207
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
	 * If the user tries to update a plugin while an update is
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
	 * already happening, it can be placed in this queue to perform later.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
	 * @since 4.2.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   212
	 * @since 4.6.0 More accurately named `queue`.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   214
	 * @type {Array.object}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   216
	wp.updates.queue = [];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   219
	 * Holds a jQuery reference to return focus to when exiting the request credentials modal.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
	 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   223
	 * @type {jQuery}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   225
	wp.updates.$elToReturnFocusToFromCredentialsModal = undefined;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   228
	 * Adds or updates an admin notice.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   229
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   230
	 * @since 4.6.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   232
	 * @param {Object}  data
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   233
	 * @param {*=}      data.selector      Optional. Selector of an element to be replaced with the admin notice.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   234
	 * @param {string=} data.id            Optional. Unique id that will be used as the notice's id attribute.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   235
	 * @param {string=} data.className     Optional. Class names that will be used in the admin notice.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   236
	 * @param {string=} data.message       Optional. The message displayed in the notice.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   237
	 * @param {number=} data.successes     Optional. The amount of successful operations.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   238
	 * @param {number=} data.errors        Optional. The amount of failed operations.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   239
	 * @param {Array=}  data.errorMessages Optional. Error messages of failed operations.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   242
	wp.updates.addAdminNotice = function( data ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   243
		var $notice = $( data.selector ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   244
			$headerEnd = $( '.wp-header-end' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   245
			$adminNotice;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   247
		delete data.selector;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   248
		$adminNotice = wp.updates.adminNotice( data );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   250
		// Check if this admin notice already exists.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   251
		if ( ! $notice.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   252
			$notice = $( '#' + data.id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   253
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   255
		if ( $notice.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   256
			$notice.replaceWith( $adminNotice );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   257
		} else if ( $headerEnd.length ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   258
			$headerEnd.after( $adminNotice );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   259
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   260
			if ( 'customize' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   261
				$( '.customize-themes-notifications' ).append( $adminNotice );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
			} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   263
				$( '.wrap' ).find( '> h1' ).after( $adminNotice );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   266
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   267
		$document.trigger( 'wp-updates-notice-added' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
	};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   271
	 * Handles Ajax requests to WordPress.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   272
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   273
	 * @since 4.6.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   275
	 * @param {string} action The type of Ajax request ('update-plugin', 'install-theme', etc).
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   276
	 * @param {Object} data   Data that needs to be passed to the ajax callback.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   277
	 * @return {$.promise}    A jQuery promise that represents the request,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   278
	 *                        decorated with an abort() method.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   280
	wp.updates.ajax = function( action, data ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   281
		var options = {};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   282
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   283
		if ( wp.updates.ajaxLocked ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   284
			wp.updates.queue.push( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   285
				action: action,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   286
				data:   data
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   287
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   288
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   289
			// Return a Deferred object so callbacks can always be registered.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   290
			return $.Deferred();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   293
		wp.updates.ajaxLocked = true;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   294
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   295
		if ( data.success ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   296
			options.success = data.success;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   297
			delete data.success;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   300
		if ( data.error ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   301
			options.error = data.error;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   302
			delete data.error;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   305
		options.data = _.extend( data, {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   306
			action:          action,
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
			_ajax_nonce:     wp.updates.ajaxNonce,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   308
			_fs_nonce:       wp.updates.filesystemCredentials.fsNonce,
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
			username:        wp.updates.filesystemCredentials.ftp.username,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
			password:        wp.updates.filesystemCredentials.ftp.password,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
			hostname:        wp.updates.filesystemCredentials.ftp.hostname,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
			connection_type: wp.updates.filesystemCredentials.ftp.connectionType,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
			public_key:      wp.updates.filesystemCredentials.ssh.publicKey,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
			private_key:     wp.updates.filesystemCredentials.ssh.privateKey
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   315
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   316
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   317
		return wp.ajax.send( options ).always( wp.updates.ajaxAlways );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   318
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   319
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   320
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   321
	 * Actions performed after every Ajax request.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   322
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   323
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   324
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   325
	 * @param {Object}  response
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   326
	 * @param {Array=}  response.debug     Optional. Debug information.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   327
	 * @param {string=} response.errorCode Optional. Error code for an error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   328
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   329
	wp.updates.ajaxAlways = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   330
		if ( ! response.errorCode || 'unable_to_connect_to_filesystem' !== response.errorCode ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   331
			wp.updates.ajaxLocked = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   332
			wp.updates.queueChecker();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   333
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   334
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   335
		if ( 'undefined' !== typeof response.debug && window.console && window.console.log ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   336
			_.map( response.debug, function( message ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   337
				// Remove all HTML tags and write a message to the console.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   338
				window.console.log( wp.sanitize.stripTagsAndEncodeText( message ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   339
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   340
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   341
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   342
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   343
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   344
	 * Refreshes update counts everywhere on the screen.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   345
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   346
	 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   347
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   348
	wp.updates.refreshCount = function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   349
		var $adminBarUpdates              = $( '#wp-admin-bar-updates' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   350
			$dashboardNavMenuUpdateCount  = $( 'a[href="update-core.php"] .update-plugins' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   351
			$pluginsNavMenuUpdateCount    = $( 'a[href="plugins.php"] .update-plugins' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   352
			$appearanceNavMenuUpdateCount = $( 'a[href="themes.php"] .update-plugins' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   353
			itemCount;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   354
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   355
		$adminBarUpdates.find( '.ab-item' ).removeAttr( 'title' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   356
		$adminBarUpdates.find( '.ab-label' ).text( settings.totals.counts.total );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   357
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   358
		// Remove the update count from the toolbar if it's zero.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   359
		if ( 0 === settings.totals.counts.total ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   360
			$adminBarUpdates.find( '.ab-label' ).parents( 'li' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   361
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   362
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   363
		// Update the "Updates" menu item.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   364
		$dashboardNavMenuUpdateCount.each( function( index, element ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   365
			element.className = element.className.replace( /count-\d+/, 'count-' + settings.totals.counts.total );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   366
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   367
		if ( settings.totals.counts.total > 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   368
			$dashboardNavMenuUpdateCount.find( '.update-count' ).text( settings.totals.counts.total );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   369
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   370
			$dashboardNavMenuUpdateCount.remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   371
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   372
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   373
		// Update the "Plugins" menu item.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   374
		$pluginsNavMenuUpdateCount.each( function( index, element ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   375
			element.className = element.className.replace( /count-\d+/, 'count-' + settings.totals.counts.plugins );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   376
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   377
		if ( settings.totals.counts.total > 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   378
			$pluginsNavMenuUpdateCount.find( '.plugin-count' ).text( settings.totals.counts.plugins );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   379
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   380
			$pluginsNavMenuUpdateCount.remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   381
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   382
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   383
		// Update the "Appearance" menu item.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   384
		$appearanceNavMenuUpdateCount.each( function( index, element ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   385
			element.className = element.className.replace( /count-\d+/, 'count-' + settings.totals.counts.themes );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   386
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   387
		if ( settings.totals.counts.total > 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   388
			$appearanceNavMenuUpdateCount.find( '.theme-count' ).text( settings.totals.counts.themes );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   389
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   390
			$appearanceNavMenuUpdateCount.remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   391
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   392
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   393
		// Update list table filter navigation.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   394
		if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   395
			itemCount = settings.totals.counts.plugins;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   396
		} else if ( 'themes' === pagenow || 'themes-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   397
			itemCount = settings.totals.counts.themes;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   398
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   399
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   400
		if ( itemCount > 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   401
			$( '.subsubsub .upgrade .count' ).text( '(' + itemCount + ')' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   402
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   403
			$( '.subsubsub .upgrade' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   404
			$( '.subsubsub li:last' ).html( function() { return $( this ).children(); } );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   405
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   406
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   407
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   408
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   409
	 * Decrements the update counts throughout the various menus.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   410
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   411
	 * This includes the toolbar, the "Updates" menu item and the menu items
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   412
	 * for plugins and themes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   413
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   414
	 * @since 3.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   415
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   416
	 * @param {string} type The type of item that was updated or deleted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   417
	 *                      Can be 'plugin', 'theme'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   418
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   419
	wp.updates.decrementCount = function( type ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   420
		settings.totals.counts.total = Math.max( --settings.totals.counts.total, 0 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   421
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   422
		if ( 'plugin' === type ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   423
			settings.totals.counts.plugins = Math.max( --settings.totals.counts.plugins, 0 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   424
		} else if ( 'theme' === type ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   425
			settings.totals.counts.themes = Math.max( --settings.totals.counts.themes, 0 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   426
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   427
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   428
		wp.updates.refreshCount( type );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   429
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   430
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   431
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   432
	 * Sends an Ajax request to the server to update a plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   433
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   434
	 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   435
	 * @since 4.6.0 More accurately named `updatePlugin`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   436
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   437
	 * @param {Object}               args         Arguments.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   438
	 * @param {string}               args.plugin  Plugin basename.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   439
	 * @param {string}               args.slug    Plugin slug.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   440
	 * @param {updatePluginSuccess=} args.success Optional. Success callback. Default: wp.updates.updatePluginSuccess
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   441
	 * @param {updatePluginError=}   args.error   Optional. Error callback. Default: wp.updates.updatePluginError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   442
	 * @return {$.promise} A jQuery promise that represents the request,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   443
	 *                     decorated with an abort() method.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   444
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   445
	wp.updates.updatePlugin = function( args ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   446
		var $updateRow, $card, $message, message,
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   447
			$adminBarUpdates = $( '#wp-admin-bar-updates' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   448
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   449
		args = _.extend( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   450
			success: wp.updates.updatePluginSuccess,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   451
			error: wp.updates.updatePluginError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   452
		}, args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   453
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   454
		if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   455
			$updateRow = $( 'tr[data-plugin="' + args.plugin + '"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   456
			$message   = $updateRow.find( '.update-message' ).removeClass( 'notice-error' ).addClass( 'updating-message notice-warning' ).find( 'p' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   457
			message    = sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   458
				/* translators: %s: Plugin name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   459
 				_x( 'Updating %s...', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   460
				$updateRow.find( '.plugin-title strong' ).text()
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   461
			);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   462
		} else if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   463
			$card    = $( '.plugin-card-' + args.slug );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   464
			$message = $card.find( '.update-now' ).addClass( 'updating-message' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   465
			message    = sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   466
				/* translators: %s: Plugin name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   467
 				_x( 'Updating %s...', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   468
				$message.data( 'name' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   469
			);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   470
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   471
			// Remove previous error messages, if any.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   472
			$card.removeClass( 'plugin-card-update-failed' ).find( '.notice.notice-error' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   473
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   474
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   475
		$adminBarUpdates.addClass( 'spin' );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   476
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   477
		if ( $message.html() !== __( 'Updating...' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   478
			$message.data( 'originaltext', $message.html() );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   479
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   480
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   481
		$message
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   482
			.attr( 'aria-label', message )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   483
			.text( __( 'Updating...' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   484
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   485
		$document.trigger( 'wp-plugin-updating', args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   486
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   487
		return wp.updates.ajax( 'update-plugin', args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   488
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   489
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   490
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   491
	 * Updates the UI appropriately after a successful plugin update.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   492
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   493
	 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   494
	 * @since 4.6.0 More accurately named `updatePluginSuccess`.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   495
	 * @since 5.5.0 Auto-update "time to next update" text cleared.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   496
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   497
	 * @param {Object} response            Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   498
	 * @param {string} response.slug       Slug of the plugin to be updated.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   499
	 * @param {string} response.plugin     Basename of the plugin to be updated.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   500
	 * @param {string} response.pluginName Name of the plugin to be updated.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   501
	 * @param {string} response.oldVersion Old version of the plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   502
	 * @param {string} response.newVersion New version of the plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   503
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   504
	wp.updates.updatePluginSuccess = function( response ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   505
		var $pluginRow, $updateMessage, newText,
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   506
			$adminBarUpdates = $( '#wp-admin-bar-updates' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   507
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   508
		if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   509
			$pluginRow     = $( 'tr[data-plugin="' + response.plugin + '"]' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   510
				.removeClass( 'update' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   511
				.addClass( 'updated' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   512
			$updateMessage = $pluginRow.find( '.update-message' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   513
				.removeClass( 'updating-message notice-warning' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   514
				.addClass( 'updated-message notice-success' ).find( 'p' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   515
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   516
			// Update the version number in the row.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   517
			newText = $pluginRow.find( '.plugin-version-author-uri' ).html().replace( response.oldVersion, response.newVersion );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   518
			$pluginRow.find( '.plugin-version-author-uri' ).html( newText );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   519
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   520
			// Clear the "time to next auto-update" text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   521
			$pluginRow.find( '.auto-update-time' ).empty();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   522
		} else if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   523
			$updateMessage = $( '.plugin-card-' + response.slug ).find( '.update-now' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   524
				.removeClass( 'updating-message' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   525
				.addClass( 'button-disabled updated-message' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   526
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   527
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   528
		$adminBarUpdates.removeClass( 'spin' );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   529
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   530
		$updateMessage
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   531
			.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   532
				'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   533
				sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   534
					/* translators: %s: Plugin name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   535
					_x( '%s updated!', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   536
					response.pluginName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   537
				)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   538
			)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   539
			.text( _x( 'Updated!', 'plugin' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   540
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   541
		wp.a11y.speak( __( 'Update completed successfully.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   542
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   543
		wp.updates.decrementCount( 'plugin' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   544
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   545
		$document.trigger( 'wp-plugin-update-success', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   546
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   547
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   548
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   549
	 * Updates the UI appropriately after a failed plugin update.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   550
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   551
	 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   552
	 * @since 4.6.0 More accurately named `updatePluginError`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   553
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   554
	 * @param {Object}  response              Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   555
	 * @param {string}  response.slug         Slug of the plugin to be updated.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   556
	 * @param {string}  response.plugin       Basename of the plugin to be updated.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   557
	 * @param {string=} response.pluginName   Optional. Name of the plugin to be updated.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   558
	 * @param {string}  response.errorCode    Error code for the error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   559
	 * @param {string}  response.errorMessage The error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   560
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   561
	wp.updates.updatePluginError = function( response ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   562
		var $card, $message, errorMessage,
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   563
			$adminBarUpdates = $( '#wp-admin-bar-updates' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   564
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   565
		if ( ! wp.updates.isValidResponse( response, 'update' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   566
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   567
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   568
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   569
		if ( wp.updates.maybeHandleCredentialError( response, 'update-plugin' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   570
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   571
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   572
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   573
		errorMessage = sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   574
			/* translators: %s: Error string for a failed update. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   575
			__( 'Update failed: %s' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   576
			response.errorMessage
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   577
		);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   578
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   579
		if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   580
			if ( response.plugin ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   581
				$message = $( 'tr[data-plugin="' + response.plugin + '"]' ).find( '.update-message' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   582
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   583
				$message = $( 'tr[data-slug="' + response.slug + '"]' ).find( '.update-message' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   584
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   585
			$message.removeClass( 'updating-message notice-warning' ).addClass( 'notice-error' ).find( 'p' ).html( errorMessage );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   586
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   587
			if ( response.pluginName ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   588
				$message.find( 'p' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   589
					.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   590
						'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   591
						sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   592
							/* translators: %s: Plugin name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   593
							_x( '%s update failed.', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   594
							response.pluginName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   595
						)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   596
					);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   597
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   598
				$message.find( 'p' ).removeAttr( 'aria-label' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   599
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   600
		} else if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   601
			$card = $( '.plugin-card-' + response.slug )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   602
				.addClass( 'plugin-card-update-failed' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   603
				.append( wp.updates.adminNotice( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   604
					className: 'update-message notice-error notice-alt is-dismissible',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   605
					message:   errorMessage
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   606
				} ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   607
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   608
			$card.find( '.update-now' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   609
				.text(  __( 'Update failed.' ) )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   610
				.removeClass( 'updating-message' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   612
			if ( response.pluginName ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   613
				$card.find( '.update-now' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   614
					.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   615
						'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   616
						sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   617
							/* translators: %s: Plugin name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   618
							_x( '%s update failed.', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   619
							response.pluginName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   620
						)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   621
					);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   622
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   623
				$card.find( '.update-now' ).removeAttr( 'aria-label' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   624
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   625
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   626
			$card.on( 'click', '.notice.is-dismissible .notice-dismiss', function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   627
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   628
				// Use same delay as the total duration of the notice fadeTo + slideUp animation.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   629
				setTimeout( function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   630
					$card
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   631
						.removeClass( 'plugin-card-update-failed' )
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   632
						.find( '.column-name a' ).trigger( 'focus' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   633
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   634
					$card.find( '.update-now' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   635
						.attr( 'aria-label', false )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   636
						.text( __( 'Update Now' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   637
				}, 200 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   638
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   639
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   640
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   641
		$adminBarUpdates.removeClass( 'spin' );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   642
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   643
		wp.a11y.speak( errorMessage, 'assertive' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   644
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   645
		$document.trigger( 'wp-plugin-update-error', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   646
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   647
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   648
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   649
	 * Sends an Ajax request to the server to install a plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   650
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   651
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   652
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   653
	 * @param {Object}                args         Arguments.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   654
	 * @param {string}                args.slug    Plugin identifier in the WordPress.org Plugin repository.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   655
	 * @param {installPluginSuccess=} args.success Optional. Success callback. Default: wp.updates.installPluginSuccess
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   656
	 * @param {installPluginError=}   args.error   Optional. Error callback. Default: wp.updates.installPluginError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   657
	 * @return {$.promise} A jQuery promise that represents the request,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   658
	 *                     decorated with an abort() method.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   659
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   660
	wp.updates.installPlugin = function( args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   661
		var $card    = $( '.plugin-card-' + args.slug ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   662
			$message = $card.find( '.install-now' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   663
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   664
		args = _.extend( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   665
			success: wp.updates.installPluginSuccess,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   666
			error: wp.updates.installPluginError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   667
		}, args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   668
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   669
		if ( 'import' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   670
			$message = $( '[data-slug="' + args.slug + '"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   671
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   672
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   673
		if ( $message.html() !== __( 'Installing...' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   674
			$message.data( 'originaltext', $message.html() );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   675
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   676
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   677
		$message
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   678
			.addClass( 'updating-message' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   679
			.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   680
				'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   681
				sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   682
					/* translators: %s: Plugin name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   683
					_x( 'Installing %s...', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   684
					$message.data( 'name' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   685
				)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   686
			)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   687
			.text( __( 'Installing...' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   688
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   689
		wp.a11y.speak( __( 'Installing... please wait.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   690
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   691
		// Remove previous error messages, if any.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   692
		$card.removeClass( 'plugin-card-install-failed' ).find( '.notice.notice-error' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   693
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   694
		$document.trigger( 'wp-plugin-installing', args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   695
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   696
		return wp.updates.ajax( 'install-plugin', args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   697
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   698
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   699
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   700
	 * Updates the UI appropriately after a successful plugin install.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   701
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   702
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   703
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   704
	 * @param {Object} response             Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   705
	 * @param {string} response.slug        Slug of the installed plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   706
	 * @param {string} response.pluginName  Name of the installed plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   707
	 * @param {string} response.activateUrl URL to activate the just installed plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   708
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   709
	wp.updates.installPluginSuccess = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   710
		var $message = $( '.plugin-card-' + response.slug ).find( '.install-now' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   711
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   712
		$message
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   713
			.removeClass( 'updating-message' )
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   714
			.addClass( 'updated-message installed button-disabled' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   715
			.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   716
				'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   717
				sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   718
					/* translators: %s: Plugin name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   719
					_x( '%s installed!', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   720
					response.pluginName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   721
				)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   722
			)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   723
			.text( _x( 'Installed!', 'plugin' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   724
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   725
		wp.a11y.speak( __( 'Installation completed successfully.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   726
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   727
		$document.trigger( 'wp-plugin-install-success', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   728
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   729
		if ( response.activateUrl ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   730
			setTimeout( function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   731
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   732
				// Transform the 'Install' button into an 'Activate' button.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   733
				$message.removeClass( 'install-now installed button-disabled updated-message' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   734
					.addClass( 'activate-now button-primary' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   735
					.attr( 'href', response.activateUrl );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   736
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   737
				if ( 'plugins-network' === pagenow ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   738
					$message
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   739
						.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   740
							'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   741
							sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   742
								/* translators: %s: Plugin name. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   743
								_x( 'Network Activate %s', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   744
								response.pluginName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   745
							)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   746
						)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   747
						.text( __( 'Network Activate' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   748
				} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   749
					$message
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   750
						.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   751
							'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   752
							sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   753
								/* translators: %s: Plugin name. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   754
								_x( 'Activate %s', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   755
								response.pluginName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   756
							)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   757
						)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   758
						.text( __( 'Activate' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   759
				}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   760
			}, 1000 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   761
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   762
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   763
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   764
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   765
	 * Updates the UI appropriately after a failed plugin install.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   766
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   767
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   768
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   769
	 * @param {Object}  response              Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   770
	 * @param {string}  response.slug         Slug of the plugin to be installed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   771
	 * @param {string=} response.pluginName   Optional. Name of the plugin to be installed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   772
	 * @param {string}  response.errorCode    Error code for the error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   773
	 * @param {string}  response.errorMessage The error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   774
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   775
	wp.updates.installPluginError = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   776
		var $card   = $( '.plugin-card-' + response.slug ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   777
			$button = $card.find( '.install-now' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   778
			errorMessage;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   779
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   780
		if ( ! wp.updates.isValidResponse( response, 'install' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   781
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   782
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   783
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   784
		if ( wp.updates.maybeHandleCredentialError( response, 'install-plugin' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   785
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   786
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   787
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   788
		errorMessage = sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   789
			/* translators: %s: Error string for a failed installation. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   790
			__( 'Installation failed: %s' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   791
			response.errorMessage
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   792
		);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   793
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   794
		$card
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   795
			.addClass( 'plugin-card-update-failed' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   796
			.append( '<div class="notice notice-error notice-alt is-dismissible"><p>' + errorMessage + '</p></div>' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   797
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   798
		$card.on( 'click', '.notice.is-dismissible .notice-dismiss', function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   799
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   800
			// Use same delay as the total duration of the notice fadeTo + slideUp animation.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   801
			setTimeout( function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   802
				$card
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   803
					.removeClass( 'plugin-card-update-failed' )
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   804
					.find( '.column-name a' ).trigger( 'focus' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   805
			}, 200 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   806
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   807
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   808
		$button
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   809
			.removeClass( 'updating-message' ).addClass( 'button-disabled' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   810
			.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   811
				'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   812
				sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   813
					/* translators: %s: Plugin name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   814
					_x( '%s installation failed', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   815
					$button.data( 'name' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   816
				)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   817
			)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   818
			.text( __( 'Installation failed.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   819
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   820
		wp.a11y.speak( errorMessage, 'assertive' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   821
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   822
		$document.trigger( 'wp-plugin-install-error', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   823
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   824
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   825
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   826
	 * Updates the UI appropriately after a successful importer install.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   827
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   828
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   829
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   830
	 * @param {Object} response             Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   831
	 * @param {string} response.slug        Slug of the installed plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   832
	 * @param {string} response.pluginName  Name of the installed plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   833
	 * @param {string} response.activateUrl URL to activate the just installed plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   834
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   835
	wp.updates.installImporterSuccess = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   836
		wp.updates.addAdminNotice( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   837
			id:        'install-success',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   838
			className: 'notice-success is-dismissible',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   839
			message:   sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   840
				/* translators: %s: Activation URL. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   841
				__( 'Importer installed successfully. <a href="%s">Run importer</a>' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   842
				response.activateUrl + '&from=import'
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   843
			)
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   844
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   845
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   846
		$( '[data-slug="' + response.slug + '"]' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   847
			.removeClass( 'install-now updating-message' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   848
			.addClass( 'activate-now' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   849
			.attr({
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   850
				'href': response.activateUrl + '&from=import',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   851
				'aria-label':sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   852
					/* translators: %s: Importer name. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   853
					__( 'Run %s' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   854
					response.pluginName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   855
				)
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   856
			})
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   857
			.text( __( 'Run Importer' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   858
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   859
		wp.a11y.speak( __( 'Installation completed successfully.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   860
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   861
		$document.trigger( 'wp-importer-install-success', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   862
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   863
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   864
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   865
	 * Updates the UI appropriately after a failed importer install.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   866
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   867
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   868
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   869
	 * @param {Object}  response              Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   870
	 * @param {string}  response.slug         Slug of the plugin to be installed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   871
	 * @param {string=} response.pluginName   Optional. Name of the plugin to be installed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   872
	 * @param {string}  response.errorCode    Error code for the error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   873
	 * @param {string}  response.errorMessage The error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   874
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   875
	wp.updates.installImporterError = function( response ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   876
		var errorMessage = sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   877
				/* translators: %s: Error string for a failed installation. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   878
				__( 'Installation failed: %s' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   879
				response.errorMessage
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   880
			),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   881
			$installLink = $( '[data-slug="' + response.slug + '"]' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   882
			pluginName = $installLink.data( 'name' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   883
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   884
		if ( ! wp.updates.isValidResponse( response, 'install' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   885
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   886
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   887
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   888
		if ( wp.updates.maybeHandleCredentialError( response, 'install-plugin' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   889
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   890
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   891
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   892
		wp.updates.addAdminNotice( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   893
			id:        response.errorCode,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   894
			className: 'notice-error is-dismissible',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   895
			message:   errorMessage
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   896
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   897
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   898
		$installLink
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   899
			.removeClass( 'updating-message' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   900
			.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   901
				'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   902
				sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   903
					/* translators: %s: Plugin name. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   904
					_x( 'Install %s now', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   905
					pluginName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   906
				)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   907
			)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   908
			.text( __( 'Install Now' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   909
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   910
		wp.a11y.speak( errorMessage, 'assertive' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   911
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   912
		$document.trigger( 'wp-importer-install-error', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   913
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   914
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   915
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   916
	 * Sends an Ajax request to the server to delete a plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   917
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   918
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   919
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   920
	 * @param {Object}               args         Arguments.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   921
	 * @param {string}               args.plugin  Basename of the plugin to be deleted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   922
	 * @param {string}               args.slug    Slug of the plugin to be deleted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   923
	 * @param {deletePluginSuccess=} args.success Optional. Success callback. Default: wp.updates.deletePluginSuccess
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   924
	 * @param {deletePluginError=}   args.error   Optional. Error callback. Default: wp.updates.deletePluginError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   925
	 * @return {$.promise} A jQuery promise that represents the request,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   926
	 *                     decorated with an abort() method.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   927
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   928
	wp.updates.deletePlugin = function( args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   929
		var $link = $( '[data-plugin="' + args.plugin + '"]' ).find( '.row-actions a.delete' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   930
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   931
		args = _.extend( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   932
			success: wp.updates.deletePluginSuccess,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   933
			error: wp.updates.deletePluginError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   934
		}, args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   935
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   936
		if ( $link.html() !== __( 'Deleting...' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   937
			$link
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   938
				.data( 'originaltext', $link.html() )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   939
				.text( __( 'Deleting...' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   940
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   941
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   942
		wp.a11y.speak( __( 'Deleting...' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   943
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   944
		$document.trigger( 'wp-plugin-deleting', args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   945
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   946
		return wp.updates.ajax( 'delete-plugin', args );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   947
	};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   948
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   949
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   950
	 * Updates the UI appropriately after a successful plugin deletion.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   951
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   952
	 * @since 4.6.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
	 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   954
	 * @param {Object} response            Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   955
	 * @param {string} response.slug       Slug of the plugin that was deleted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   956
	 * @param {string} response.plugin     Base name of the plugin that was deleted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   957
	 * @param {string} response.pluginName Name of the plugin that was deleted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   958
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   959
	wp.updates.deletePluginSuccess = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   960
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   961
		// Removes the plugin and updates rows.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   962
		$( '[data-plugin="' + response.plugin + '"]' ).css( { backgroundColor: '#faafaa' } ).fadeOut( 350, function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   963
			var $form            = $( '#bulk-action-form' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   964
				$views           = $( '.subsubsub' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   965
				$pluginRow       = $( this ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   966
				columnCount      = $form.find( 'thead th:not(.hidden), thead td' ).length,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   967
				pluginDeletedRow = wp.template( 'item-deleted-row' ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   968
				/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   969
				 * Plugins Base names of plugins in their different states.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   970
				 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   971
				 * @type {Object}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   972
				 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   973
				plugins          = settings.plugins;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   974
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   975
			// Add a success message after deleting a plugin.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   976
			if ( ! $pluginRow.hasClass( 'plugin-update-tr' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   977
				$pluginRow.after(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   978
					pluginDeletedRow( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   979
						slug:    response.slug,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   980
						plugin:  response.plugin,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   981
						colspan: columnCount,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   982
						name:    response.pluginName
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   983
					} )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   984
				);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   985
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   986
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   987
			$pluginRow.remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   988
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   989
			// Remove plugin from update count.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   990
			if ( -1 !== _.indexOf( plugins.upgrade, response.plugin ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   991
				plugins.upgrade = _.without( plugins.upgrade, response.plugin );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   992
				wp.updates.decrementCount( 'plugin' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   993
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   994
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   995
			// Remove from views.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   996
			if ( -1 !== _.indexOf( plugins.inactive, response.plugin ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   997
				plugins.inactive = _.without( plugins.inactive, response.plugin );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   998
				if ( plugins.inactive.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   999
					$views.find( '.inactive .count' ).text( '(' + plugins.inactive.length + ')' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1000
				} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1001
					$views.find( '.inactive' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1002
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1003
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1004
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1005
			if ( -1 !== _.indexOf( plugins.active, response.plugin ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1006
				plugins.active = _.without( plugins.active, response.plugin );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1007
				if ( plugins.active.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1008
					$views.find( '.active .count' ).text( '(' + plugins.active.length + ')' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1009
				} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1010
					$views.find( '.active' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1011
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1012
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1013
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1014
			if ( -1 !== _.indexOf( plugins.recently_activated, response.plugin ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1015
				plugins.recently_activated = _.without( plugins.recently_activated, response.plugin );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1016
				if ( plugins.recently_activated.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1017
					$views.find( '.recently_activated .count' ).text( '(' + plugins.recently_activated.length + ')' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1018
				} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1019
					$views.find( '.recently_activated' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1020
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1021
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1022
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1023
			if ( -1 !== _.indexOf( plugins['auto-update-enabled'], response.plugin ) ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1024
				plugins['auto-update-enabled'] = _.without( plugins['auto-update-enabled'], response.plugin );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1025
				if ( plugins['auto-update-enabled'].length ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1026
					$views.find( '.auto-update-enabled .count' ).text( '(' + plugins['auto-update-enabled'].length + ')' );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1027
				} else {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1028
					$views.find( '.auto-update-enabled' ).remove();
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1029
				}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1030
			}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1031
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1032
			if ( -1 !== _.indexOf( plugins['auto-update-disabled'], response.plugin ) ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1033
				plugins['auto-update-disabled'] = _.without( plugins['auto-update-disabled'], response.plugin );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1034
				if ( plugins['auto-update-disabled'].length ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1035
					$views.find( '.auto-update-disabled .count' ).text( '(' + plugins['auto-update-disabled'].length + ')' );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1036
				} else {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1037
					$views.find( '.auto-update-disabled' ).remove();
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1038
				}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1039
			}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1040
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1041
			plugins.all = _.without( plugins.all, response.plugin );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1042
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1043
			if ( plugins.all.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1044
				$views.find( '.all .count' ).text( '(' + plugins.all.length + ')' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1045
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1046
				$form.find( '.tablenav' ).css( { visibility: 'hidden' } );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1047
				$views.find( '.all' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1048
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1049
				if ( ! $form.find( 'tr.no-items' ).length ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1050
					$form.find( '#the-list' ).append( '<tr class="no-items"><td class="colspanchange" colspan="' + columnCount + '">' + __( 'No plugins are currently available.' ) + '</td></tr>' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1051
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1052
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1053
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1054
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1055
		wp.a11y.speak( _x( 'Deleted!', 'plugin' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1056
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1057
		$document.trigger( 'wp-plugin-delete-success', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1058
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1059
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1060
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1061
	 * Updates the UI appropriately after a failed plugin deletion.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1062
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1063
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1064
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1065
	 * @param {Object}  response              Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1066
	 * @param {string}  response.slug         Slug of the plugin to be deleted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1067
	 * @param {string}  response.plugin       Base name of the plugin to be deleted
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1068
	 * @param {string=} response.pluginName   Optional. Name of the plugin to be deleted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1069
	 * @param {string}  response.errorCode    Error code for the error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1070
	 * @param {string}  response.errorMessage The error that occurred.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1072
	wp.updates.deletePluginError = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1073
		var $plugin, $pluginUpdateRow,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1074
			pluginUpdateRow  = wp.template( 'item-update-row' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1075
			noticeContent    = wp.updates.adminNotice( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1076
				className: 'update-message notice-error notice-alt',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1077
				message:   response.errorMessage
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1078
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1079
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1080
		if ( response.plugin ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1081
			$plugin          = $( 'tr.inactive[data-plugin="' + response.plugin + '"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1082
			$pluginUpdateRow = $plugin.siblings( '[data-plugin="' + response.plugin + '"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1083
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1084
			$plugin          = $( 'tr.inactive[data-slug="' + response.slug + '"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1085
			$pluginUpdateRow = $plugin.siblings( '[data-slug="' + response.slug + '"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1086
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1087
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1088
		if ( ! wp.updates.isValidResponse( response, 'delete' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1089
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1090
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1091
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1092
		if ( wp.updates.maybeHandleCredentialError( response, 'delete-plugin' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1093
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1094
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1095
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1096
		// Add a plugin update row if it doesn't exist yet.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1097
		if ( ! $pluginUpdateRow.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1098
			$plugin.addClass( 'update' ).after(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1099
				pluginUpdateRow( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1100
					slug:    response.slug,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1101
					plugin:  response.plugin || response.slug,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1102
					colspan: $( '#bulk-action-form' ).find( 'thead th:not(.hidden), thead td' ).length,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1103
					content: noticeContent
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1104
				} )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1105
			);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1106
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1107
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1108
			// Remove previous error messages, if any.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1109
			$pluginUpdateRow.find( '.notice-error' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1110
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1111
			$pluginUpdateRow.find( '.plugin-update' ).append( noticeContent );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1112
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1113
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1114
		$document.trigger( 'wp-plugin-delete-error', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1115
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1116
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1117
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1118
	 * Sends an Ajax request to the server to update a theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1119
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1120
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1121
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1122
	 * @param {Object}              args         Arguments.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1123
	 * @param {string}              args.slug    Theme stylesheet.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1124
	 * @param {updateThemeSuccess=} args.success Optional. Success callback. Default: wp.updates.updateThemeSuccess
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1125
	 * @param {updateThemeError=}   args.error   Optional. Error callback. Default: wp.updates.updateThemeError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1126
	 * @return {$.promise} A jQuery promise that represents the request,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1127
	 *                     decorated with an abort() method.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1128
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1129
	wp.updates.updateTheme = function( args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1130
		var $notice;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1131
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1132
		args = _.extend( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1133
			success: wp.updates.updateThemeSuccess,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1134
			error: wp.updates.updateThemeError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1135
		}, args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1136
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1137
		if ( 'themes-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1138
			$notice = $( '[data-slug="' + args.slug + '"]' ).find( '.update-message' ).removeClass( 'notice-error' ).addClass( 'updating-message notice-warning' ).find( 'p' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1139
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1140
		} else if ( 'customize' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1141
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1142
			// Update the theme details UI.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1143
			$notice = $( '[data-slug="' + args.slug + '"].notice' ).removeClass( 'notice-large' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1144
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1145
			$notice.find( 'h3' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1146
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1147
			// Add the top-level UI, and update both.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1148
			$notice = $notice.add( $( '#customize-control-installed_theme_' + args.slug ).find( '.update-message' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1149
			$notice = $notice.addClass( 'updating-message' ).find( 'p' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1150
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1151
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1152
			$notice = $( '#update-theme' ).closest( '.notice' ).removeClass( 'notice-large' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1153
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1154
			$notice.find( 'h3' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1155
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1156
			$notice = $notice.add( $( '[data-slug="' + args.slug + '"]' ).find( '.update-message' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1157
			$notice = $notice.addClass( 'updating-message' ).find( 'p' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1158
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1159
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1160
		if ( $notice.html() !== __( 'Updating...' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1161
			$notice.data( 'originaltext', $notice.html() );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1162
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1163
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1164
		wp.a11y.speak( __( 'Updating... please wait.' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1165
		$notice.text( __( 'Updating...' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1166
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1167
		$document.trigger( 'wp-theme-updating', args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1168
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1169
		return wp.updates.ajax( 'update-theme', args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1170
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1171
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1172
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1173
	 * Updates the UI appropriately after a successful theme update.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1174
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1175
	 * @since 4.6.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1176
	 * @since 5.5.0 Auto-update "time to next update" text cleared.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1177
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1178
	 * @param {Object} response
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1179
	 * @param {string} response.slug       Slug of the theme to be updated.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1180
	 * @param {Object} response.theme      Updated theme.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1181
	 * @param {string} response.oldVersion Old version of the theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1182
	 * @param {string} response.newVersion New version of the theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1183
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1184
	wp.updates.updateThemeSuccess = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1185
		var isModalOpen    = $( 'body.modal-open' ).length,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1186
			$theme         = $( '[data-slug="' + response.slug + '"]' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1187
			updatedMessage = {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1188
				className: 'updated-message notice-success notice-alt',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1189
				message:   _x( 'Updated!', 'theme' )
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1190
			},
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1191
			$notice, newText;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1192
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1193
		if ( 'customize' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1194
			$theme = $( '.updating-message' ).siblings( '.theme-name' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1195
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1196
			if ( $theme.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1197
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1198
				// Update the version number in the row.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1199
				newText = $theme.html().replace( response.oldVersion, response.newVersion );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1200
				$theme.html( newText );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1201
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1202
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1203
			$notice = $( '.theme-info .notice' ).add( wp.customize.control( 'installed_theme_' + response.slug ).container.find( '.theme' ).find( '.update-message' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1204
		} else if ( 'themes-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1205
			$notice = $theme.find( '.update-message' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1206
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1207
			// Update the version number in the row.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1208
			newText = $theme.find( '.theme-version-author-uri' ).html().replace( response.oldVersion, response.newVersion );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1209
			$theme.find( '.theme-version-author-uri' ).html( newText );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1210
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1211
			// Clear the "time to next auto-update" text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1212
			$theme.find( '.auto-update-time' ).empty();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1213
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1214
			$notice = $( '.theme-info .notice' ).add( $theme.find( '.update-message' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1215
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1216
			// Focus on Customize button after updating.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1217
			if ( isModalOpen ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1218
				$( '.load-customize:visible' ).trigger( 'focus' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1219
				$( '.theme-info .theme-autoupdate' ).find( '.auto-update-time' ).empty();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1220
			} else {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1221
				$theme.find( '.load-customize' ).trigger( 'focus' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1222
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1223
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1224
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1225
		wp.updates.addAdminNotice( _.extend( { selector: $notice }, updatedMessage ) );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1226
		wp.a11y.speak( __( 'Update completed successfully.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1227
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1228
		wp.updates.decrementCount( 'theme' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1229
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1230
		$document.trigger( 'wp-theme-update-success', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1231
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1232
		// Show updated message after modal re-rendered.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1233
		if ( isModalOpen && 'customize' !== pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1234
			$( '.theme-info .theme-author' ).after( wp.updates.adminNotice( updatedMessage ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1235
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1236
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1237
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1238
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1239
	 * Updates the UI appropriately after a failed theme update.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1240
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1241
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1242
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1243
	 * @param {Object} response              Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1244
	 * @param {string} response.slug         Slug of the theme to be updated.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1245
	 * @param {string} response.errorCode    Error code for the error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1246
	 * @param {string} response.errorMessage The error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1247
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1248
	wp.updates.updateThemeError = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1249
		var $theme       = $( '[data-slug="' + response.slug + '"]' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1250
			errorMessage = sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1251
				/* translators: %s: Error string for a failed update. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1252
				 __( 'Update failed: %s' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1253
				response.errorMessage
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1254
			),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1255
			$notice;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1256
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1257
		if ( ! wp.updates.isValidResponse( response, 'update' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1258
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1259
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1260
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1261
		if ( wp.updates.maybeHandleCredentialError( response, 'update-theme' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1262
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1263
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1264
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1265
		if ( 'customize' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1266
			$theme = wp.customize.control( 'installed_theme_' + response.slug ).container.find( '.theme' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1267
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1268
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1269
		if ( 'themes-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1270
			$notice = $theme.find( '.update-message ' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1271
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1272
			$notice = $( '.theme-info .notice' ).add( $theme.find( '.notice' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1273
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1274
			$( 'body.modal-open' ).length ? $( '.load-customize:visible' ).trigger( 'focus' ) : $theme.find( '.load-customize' ).trigger( 'focus');
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1275
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1276
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1277
		wp.updates.addAdminNotice( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1278
			selector:  $notice,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1279
			className: 'update-message notice-error notice-alt is-dismissible',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1280
			message:   errorMessage
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1281
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1282
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1283
		wp.a11y.speak( errorMessage );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1284
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1285
		$document.trigger( 'wp-theme-update-error', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1286
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1287
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1288
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1289
	 * Sends an Ajax request to the server to install a theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1290
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1291
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1292
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1293
	 * @param {Object}               args
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1294
	 * @param {string}               args.slug    Theme stylesheet.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1295
	 * @param {installThemeSuccess=} args.success Optional. Success callback. Default: wp.updates.installThemeSuccess
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1296
	 * @param {installThemeError=}   args.error   Optional. Error callback. Default: wp.updates.installThemeError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1297
	 * @return {$.promise} A jQuery promise that represents the request,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1298
	 *                     decorated with an abort() method.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1299
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1300
	wp.updates.installTheme = function( args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1301
		var $message = $( '.theme-install[data-slug="' + args.slug + '"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1302
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1303
		args = _.extend( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1304
			success: wp.updates.installThemeSuccess,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1305
			error: wp.updates.installThemeError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1306
		}, args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1307
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1308
		$message.addClass( 'updating-message' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1309
		$message.parents( '.theme' ).addClass( 'focus' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1310
		if ( $message.html() !== __( 'Installing...' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1311
			$message.data( 'originaltext', $message.html() );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1312
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1313
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1314
		$message
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1315
			.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1316
				'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1317
				sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1318
					/* translators: %s: Theme name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1319
					_x( 'Installing %s...', 'theme' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1320
					$message.data( 'name' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1321
				)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1322
			)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1323
			.text( __( 'Installing...' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1324
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1325
		wp.a11y.speak( __( 'Installing... please wait.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1326
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1327
		// Remove previous error messages, if any.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1328
		$( '.install-theme-info, [data-slug="' + args.slug + '"]' ).removeClass( 'theme-install-failed' ).find( '.notice.notice-error' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1329
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1330
		$document.trigger( 'wp-theme-installing', args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1331
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1332
		return wp.updates.ajax( 'install-theme', args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1333
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1334
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1335
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1336
	 * Updates the UI appropriately after a successful theme install.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1337
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1338
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1339
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1340
	 * @param {Object} response              Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1341
	 * @param {string} response.slug         Slug of the theme to be installed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1342
	 * @param {string} response.customizeUrl URL to the Customizer for the just installed theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1343
	 * @param {string} response.activateUrl  URL to activate the just installed theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1344
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1345
	wp.updates.installThemeSuccess = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1346
		var $card = $( '.wp-full-overlay-header, [data-slug=' + response.slug + ']' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1347
			$message;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1348
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1349
		$document.trigger( 'wp-theme-install-success', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1350
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1351
		$message = $card.find( '.button-primary' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1352
			.removeClass( 'updating-message' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1353
			.addClass( 'updated-message disabled' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1354
			.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1355
				'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1356
				sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1357
					/* translators: %s: Theme name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1358
					_x( '%s installed!', 'theme' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1359
					response.themeName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1360
				)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1361
			)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1362
			.text( _x( 'Installed!', 'theme' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1363
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1364
		wp.a11y.speak( __( 'Installation completed successfully.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1365
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1366
		setTimeout( function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1367
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1368
			if ( response.activateUrl ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1369
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1370
				// Transform the 'Install' button into an 'Activate' button.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1371
				$message
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1372
					.attr( 'href', response.activateUrl )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1373
					.removeClass( 'theme-install updated-message disabled' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1374
					.addClass( 'activate' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1375
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1376
				if ( 'themes-network' === pagenow ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1377
					$message
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1378
						.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1379
							'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1380
							sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1381
								/* translators: %s: Theme name. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1382
								_x( 'Network Activate %s', 'theme' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1383
								response.themeName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1384
							)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1385
						)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1386
						.text( __( 'Network Enable' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1387
				} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1388
					$message
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1389
						.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1390
							'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1391
							sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1392
								/* translators: %s: Theme name. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1393
								_x( 'Activate %s', 'theme' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1394
								response.themeName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1395
							)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1396
						)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1397
						.text( __( 'Activate' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1398
				}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1399
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1400
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1401
			if ( response.customizeUrl ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1402
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1403
				// Transform the 'Preview' button into a 'Live Preview' button.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1404
				$message.siblings( '.preview' ).replaceWith( function () {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1405
					return $( '<a>' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1406
						.attr( 'href', response.customizeUrl )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1407
						.addClass( 'button load-customize' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1408
						.text( __( 'Live Preview' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1409
				} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1410
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1411
		}, 1000 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1412
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1413
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1414
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1415
	 * Updates the UI appropriately after a failed theme install.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1416
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1417
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1418
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1419
	 * @param {Object} response              Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1420
	 * @param {string} response.slug         Slug of the theme to be installed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1421
	 * @param {string} response.errorCode    Error code for the error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1422
	 * @param {string} response.errorMessage The error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1423
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1424
	wp.updates.installThemeError = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1425
		var $card, $button,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1426
			errorMessage = sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1427
				/* translators: %s: Error string for a failed installation. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1428
				__( 'Installation failed: %s' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1429
				response.errorMessage
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1430
			),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1431
			$message     = wp.updates.adminNotice( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1432
				className: 'update-message notice-error notice-alt',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1433
				message:   errorMessage
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1434
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1435
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1436
		if ( ! wp.updates.isValidResponse( response, 'install' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1437
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1438
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1439
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1440
		if ( wp.updates.maybeHandleCredentialError( response, 'install-theme' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1441
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1442
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1443
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1444
		if ( 'customize' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1445
			if ( $document.find( 'body' ).hasClass( 'modal-open' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1446
				$button = $( '.theme-install[data-slug="' + response.slug + '"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1447
				$card   = $( '.theme-overlay .theme-info' ).prepend( $message );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1448
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1449
				$button = $( '.theme-install[data-slug="' + response.slug + '"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1450
				$card   = $button.closest( '.theme' ).addClass( 'theme-install-failed' ).append( $message );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1451
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1452
			wp.customize.notifications.remove( 'theme_installing' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1453
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1454
			if ( $document.find( 'body' ).hasClass( 'full-overlay-active' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1455
				$button = $( '.theme-install[data-slug="' + response.slug + '"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1456
				$card   = $( '.install-theme-info' ).prepend( $message );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1457
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1458
				$card   = $( '[data-slug="' + response.slug + '"]' ).removeClass( 'focus' ).addClass( 'theme-install-failed' ).append( $message );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1459
				$button = $card.find( '.theme-install' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1460
			}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1461
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1462
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1463
		$button
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1464
			.removeClass( 'updating-message' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1465
			.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1466
				'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1467
				sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1468
					/* translators: %s: Theme name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1469
					_x( '%s installation failed', 'theme' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1470
					$button.data( 'name' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1471
				)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1472
			)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1473
			.text( __( 'Installation failed.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1474
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1475
		wp.a11y.speak( errorMessage, 'assertive' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1476
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1477
		$document.trigger( 'wp-theme-install-error', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1478
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1479
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1480
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1481
	 * Sends an Ajax request to the server to delete a theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1482
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1483
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1484
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1485
	 * @param {Object}              args
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1486
	 * @param {string}              args.slug    Theme stylesheet.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1487
	 * @param {deleteThemeSuccess=} args.success Optional. Success callback. Default: wp.updates.deleteThemeSuccess
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1488
	 * @param {deleteThemeError=}   args.error   Optional. Error callback. Default: wp.updates.deleteThemeError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1489
	 * @return {$.promise} A jQuery promise that represents the request,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1490
	 *                     decorated with an abort() method.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1491
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1492
	wp.updates.deleteTheme = function( args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1493
		var $button;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1494
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1495
		if ( 'themes' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1496
			$button = $( '.theme-actions .delete-theme' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1497
		} else if ( 'themes-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1498
			$button = $( '[data-slug="' + args.slug + '"]' ).find( '.row-actions a.delete' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1499
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1500
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1501
		args = _.extend( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1502
			success: wp.updates.deleteThemeSuccess,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1503
			error: wp.updates.deleteThemeError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1504
		}, args );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1505
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1506
		if ( $button && $button.html() !== __( 'Deleting...' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1507
			$button
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1508
				.data( 'originaltext', $button.html() )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1509
				.text( __( 'Deleting...' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1510
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1511
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1512
		wp.a11y.speak( __( 'Deleting...' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1513
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1514
		// Remove previous error messages, if any.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1515
		$( '.theme-info .update-message' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1516
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1517
		$document.trigger( 'wp-theme-deleting', args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1518
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1519
		return wp.updates.ajax( 'delete-theme', args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1520
	};
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1521
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1522
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1523
	 * Updates the UI appropriately after a successful theme deletion.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1524
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1525
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1526
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1527
	 * @param {Object} response      Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1528
	 * @param {string} response.slug Slug of the theme that was deleted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1529
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1530
	wp.updates.deleteThemeSuccess = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1531
		var $themeRows = $( '[data-slug="' + response.slug + '"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1532
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1533
		if ( 'themes-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1534
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1535
			// Removes the theme and updates rows.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1536
			$themeRows.css( { backgroundColor: '#faafaa' } ).fadeOut( 350, function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1537
				var $views     = $( '.subsubsub' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1538
					$themeRow  = $( this ),
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1539
					themes     = settings.themes,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1540
					deletedRow = wp.template( 'item-deleted-row' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1541
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1542
				if ( ! $themeRow.hasClass( 'plugin-update-tr' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1543
					$themeRow.after(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1544
						deletedRow( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1545
							slug:    response.slug,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1546
							colspan: $( '#bulk-action-form' ).find( 'thead th:not(.hidden), thead td' ).length,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1547
							name:    $themeRow.find( '.theme-title strong' ).text()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1548
						} )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1549
					);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1550
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1551
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1552
				$themeRow.remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1553
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1554
				// Remove theme from update count.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1555
				if ( -1 !== _.indexOf( themes.upgrade, response.slug ) ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1556
					themes.upgrade = _.without( themes.upgrade, response.slug );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1557
					wp.updates.decrementCount( 'theme' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1558
				}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1559
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1560
				// Remove from views.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1561
				if ( -1 !== _.indexOf( themes.disabled, response.slug ) ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1562
					themes.disabled = _.without( themes.disabled, response.slug );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1563
					if ( themes.disabled.length ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1564
						$views.find( '.disabled .count' ).text( '(' + themes.disabled.length + ')' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1565
					} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1566
						$views.find( '.disabled' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1567
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1568
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1569
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1570
				if ( -1 !== _.indexOf( themes['auto-update-enabled'], response.slug ) ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1571
					themes['auto-update-enabled'] = _.without( themes['auto-update-enabled'], response.slug );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1572
					if ( themes['auto-update-enabled'].length ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1573
						$views.find( '.auto-update-enabled .count' ).text( '(' + themes['auto-update-enabled'].length + ')' );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1574
					} else {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1575
						$views.find( '.auto-update-enabled' ).remove();
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1576
					}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1577
				}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1578
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1579
				if ( -1 !== _.indexOf( themes['auto-update-disabled'], response.slug ) ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1580
					themes['auto-update-disabled'] = _.without( themes['auto-update-disabled'], response.slug );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1581
					if ( themes['auto-update-disabled'].length ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1582
						$views.find( '.auto-update-disabled .count' ).text( '(' + themes['auto-update-disabled'].length + ')' );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1583
					} else {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1584
						$views.find( '.auto-update-disabled' ).remove();
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1585
					}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1586
				}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1587
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1588
				themes.all = _.without( themes.all, response.slug );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1589
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1590
				// There is always at least one theme available.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1591
				$views.find( '.all .count' ).text( '(' + themes.all.length + ')' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1592
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1593
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1594
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1595
		wp.a11y.speak( _x( 'Deleted!', 'theme' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1596
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1597
		$document.trigger( 'wp-theme-delete-success', response );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1598
	};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1599
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1600
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1601
	 * Updates the UI appropriately after a failed theme deletion.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1602
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1603
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1604
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1605
	 * @param {Object} response              Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1606
	 * @param {string} response.slug         Slug of the theme to be deleted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1607
	 * @param {string} response.errorCode    Error code for the error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1608
	 * @param {string} response.errorMessage The error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1609
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1610
	wp.updates.deleteThemeError = function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1611
		var $themeRow    = $( 'tr.inactive[data-slug="' + response.slug + '"]' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1612
			$button      = $( '.theme-actions .delete-theme' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1613
			updateRow    = wp.template( 'item-update-row' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1614
			$updateRow   = $themeRow.siblings( '#' + response.slug + '-update' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1615
			errorMessage = sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1616
				/* translators: %s: Error string for a failed deletion. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1617
				__( 'Deletion failed: %s' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1618
				response.errorMessage
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1619
			),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1620
			$message     = wp.updates.adminNotice( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1621
				className: 'update-message notice-error notice-alt',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1622
				message:   errorMessage
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1623
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1624
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1625
		if ( wp.updates.maybeHandleCredentialError( response, 'delete-theme' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1626
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1627
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1628
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1629
		if ( 'themes-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1630
			if ( ! $updateRow.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1631
				$themeRow.addClass( 'update' ).after(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1632
					updateRow( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1633
						slug: response.slug,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1634
						colspan: $( '#bulk-action-form' ).find( 'thead th:not(.hidden), thead td' ).length,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1635
						content: $message
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1636
					} )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1637
				);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1638
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1639
				// Remove previous error messages, if any.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1640
				$updateRow.find( '.notice-error' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1641
				$updateRow.find( '.plugin-update' ).append( $message );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1642
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1643
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1644
			$( '.theme-info .theme-description' ).before( $message );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1645
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1646
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1647
		$button.html( $button.data( 'originaltext' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1648
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1649
		wp.a11y.speak( errorMessage, 'assertive' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1650
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1651
		$document.trigger( 'wp-theme-delete-error', response );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1652
	};
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1653
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1654
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1655
	 * Adds the appropriate callback based on the type of action and the current page.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1656
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1657
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1658
	 * @private
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1659
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1660
	 * @param {Object} data   Ajax payload.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1661
	 * @param {string} action The type of request to perform.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1662
	 * @return {Object} The Ajax payload with the appropriate callbacks.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1663
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1664
	wp.updates._addCallbacks = function( data, action ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1665
		if ( 'import' === pagenow && 'install-plugin' === action ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1666
			data.success = wp.updates.installImporterSuccess;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1667
			data.error   = wp.updates.installImporterError;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1668
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1669
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1670
		return data;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1671
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1672
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1673
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1674
	 * Pulls available jobs from the queue and runs them.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1675
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1676
	 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1677
	 * @since 4.6.0 Can handle multiple job types.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1678
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1679
	wp.updates.queueChecker = function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1680
		var job;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1681
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1682
		if ( wp.updates.ajaxLocked || ! wp.updates.queue.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1683
			return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1684
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1685
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1686
		job = wp.updates.queue.shift();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1687
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1688
		// Handle a queue job.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1689
		switch ( job.action ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1690
			case 'install-plugin':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1691
				wp.updates.installPlugin( job.data );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1692
				break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1693
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1694
			case 'update-plugin':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1695
				wp.updates.updatePlugin( job.data );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1696
				break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1697
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1698
			case 'delete-plugin':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1699
				wp.updates.deletePlugin( job.data );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1700
				break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1701
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1702
			case 'install-theme':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1703
				wp.updates.installTheme( job.data );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1704
				break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1705
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1706
			case 'update-theme':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1707
				wp.updates.updateTheme( job.data );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1708
				break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1709
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1710
			case 'delete-theme':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1711
				wp.updates.deleteTheme( job.data );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1712
				break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1713
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1714
			default:
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1715
				break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1716
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1717
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1718
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1719
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1720
	 * Requests the users filesystem credentials if they aren't already known.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1721
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1722
	 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1723
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1724
	 * @param {Event=} event Optional. Event interface.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1725
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1726
	wp.updates.requestFilesystemCredentials = function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1727
		if ( false === wp.updates.filesystemCredentials.available ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1728
			/*
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1729
			 * After exiting the credentials request modal,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1730
			 * return the focus to the element triggering the request.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1731
			 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1732
			if ( event && ! wp.updates.$elToReturnFocusToFromCredentialsModal ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1733
				wp.updates.$elToReturnFocusToFromCredentialsModal = $( event.target );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1734
			}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1735
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1736
			wp.updates.ajaxLocked = true;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1737
			wp.updates.requestForCredentialsModalOpen();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1738
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1739
	};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1740
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1741
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1742
	 * Requests the users filesystem credentials if needed and there is no lock.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1743
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1744
	 * @since 4.6.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1745
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1746
	 * @param {Event=} event Optional. Event interface.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1747
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1748
	wp.updates.maybeRequestFilesystemCredentials = function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1749
		if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1750
			wp.updates.requestFilesystemCredentials( event );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1751
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1752
	};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1753
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1754
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1755
	 * Keydown handler for the request for credentials modal.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1756
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1757
	 * Closes the modal when the escape key is pressed and
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1758
	 * constrains keyboard navigation to inside the modal.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1759
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1760
	 * @since 4.2.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1761
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1762
	 * @param {Event} event Event interface.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1763
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1764
	wp.updates.keydown = function( event ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1765
		if ( 27 === event.keyCode ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1766
			wp.updates.requestForCredentialsModalCancel();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1767
		} else if ( 9 === event.keyCode ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1768
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1769
			// #upgrade button must always be the last focus-able element in the dialog.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1770
			if ( 'upgrade' === event.target.id && ! event.shiftKey ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1771
				$( '#hostname' ).trigger( 'focus' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1772
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1773
				event.preventDefault();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1774
			} else if ( 'hostname' === event.target.id && event.shiftKey ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1775
				$( '#upgrade' ).trigger( 'focus' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1776
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1777
				event.preventDefault();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1778
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1779
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1780
	};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1781
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1782
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1783
	 * Opens the request for credentials modal.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1784
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1785
	 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1786
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1787
	wp.updates.requestForCredentialsModalOpen = function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1788
		var $modal = $( '#request-filesystem-credentials-dialog' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1789
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1790
		$( 'body' ).addClass( 'modal-open' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1791
		$modal.show();
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1792
		$modal.find( 'input:enabled:first' ).trigger( 'focus' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1793
		$modal.on( 'keydown', wp.updates.keydown );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1794
	};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1795
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1796
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1797
	 * Closes the request for credentials modal.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1798
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1799
	 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1800
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1801
	wp.updates.requestForCredentialsModalClose = function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1802
		$( '#request-filesystem-credentials-dialog' ).hide();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1803
		$( 'body' ).removeClass( 'modal-open' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1804
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1805
		if ( wp.updates.$elToReturnFocusToFromCredentialsModal ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1806
			wp.updates.$elToReturnFocusToFromCredentialsModal.trigger( 'focus' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1807
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1808
	};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1809
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1810
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1811
	 * Takes care of the steps that need to happen when the modal is canceled out.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1812
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1813
	 * @since 4.2.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1814
	 * @since 4.6.0 Triggers an event for callbacks to listen to and add their actions.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1815
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1816
	wp.updates.requestForCredentialsModalCancel = function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1817
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1818
		// Not ajaxLocked and no queue means we already have cleared things up.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1819
		if ( ! wp.updates.ajaxLocked && ! wp.updates.queue.length ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1820
			return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1821
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1822
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1823
		_.each( wp.updates.queue, function( job ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1824
			$document.trigger( 'credential-modal-cancel', job );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1825
		} );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1826
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1827
		// Remove the lock, and clear the queue.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1828
		wp.updates.ajaxLocked = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1829
		wp.updates.queue = [];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1830
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1831
		wp.updates.requestForCredentialsModalClose();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1832
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1833
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1834
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1835
	 * Displays an error message in the request for credentials form.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1836
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1837
	 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1838
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1839
	 * @param {string} message Error message.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1840
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1841
	wp.updates.showErrorInCredentialsForm = function( message ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1842
		var $filesystemForm = $( '#request-filesystem-credentials-form' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1843
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1844
		// Remove any existing error.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1845
		$filesystemForm.find( '.notice' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1846
		$filesystemForm.find( '#request-filesystem-credentials-title' ).after( '<div class="notice notice-alt notice-error"><p>' + message + '</p></div>' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1847
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1848
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1849
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1850
	 * Handles credential errors and runs events that need to happen in that case.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1851
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1852
	 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1853
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1854
	 * @param {Object} response Ajax response.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1855
	 * @param {string} action   The type of request to perform.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1856
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1857
	wp.updates.credentialError = function( response, action ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1858
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1859
		// Restore callbacks.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1860
		response = wp.updates._addCallbacks( response, action );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1861
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1862
		wp.updates.queue.unshift( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1863
			action: action,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1864
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1865
			/*
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1866
			 * Not cool that we're depending on response for this data.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1867
			 * This would feel more whole in a view all tied together.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1868
			 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1869
			data: response
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1870
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1871
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1872
		wp.updates.filesystemCredentials.available = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1873
		wp.updates.showErrorInCredentialsForm( response.errorMessage );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1874
		wp.updates.requestFilesystemCredentials();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1875
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1876
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1877
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1878
	 * Handles credentials errors if it could not connect to the filesystem.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1879
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1880
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1881
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1882
	 * @param {Object} response              Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1883
	 * @param {string} response.errorCode    Error code for the error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1884
	 * @param {string} response.errorMessage The error that occurred.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1885
	 * @param {string} action                The type of request to perform.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1886
	 * @return {boolean} Whether there is an error that needs to be handled or not.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1887
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1888
	wp.updates.maybeHandleCredentialError = function( response, action ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1889
		if ( wp.updates.shouldRequestFilesystemCredentials && response.errorCode && 'unable_to_connect_to_filesystem' === response.errorCode ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1890
			wp.updates.credentialError( response, action );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1891
			return true;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1892
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1893
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1894
		return false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1895
	};
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1896
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1897
	/**
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1898
	 * Validates an Ajax response to ensure it's a proper object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1899
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1900
	 * If the response deems to be invalid, an admin notice is being displayed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1901
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1902
	 * @param {(Object|string)} response              Response from the server.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1903
	 * @param {function=}       response.always       Optional. Callback for when the Deferred is resolved or rejected.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1904
	 * @param {string=}         response.statusText   Optional. Status message corresponding to the status code.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1905
	 * @param {string=}         response.responseText Optional. Request response as text.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1906
	 * @param {string}          action                Type of action the response is referring to. Can be 'delete',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1907
	 *                                                'update' or 'install'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1908
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1909
	wp.updates.isValidResponse = function( response, action ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1910
		var error = __( 'Something went wrong.' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1911
			errorMessage;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1912
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1913
		// Make sure the response is a valid data object and not a Promise object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1914
		if ( _.isObject( response ) && ! _.isFunction( response.always ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1915
			return true;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1916
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1917
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1918
		if ( _.isString( response ) && '-1' === response ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1919
			error = __( 'An error has occurred. Please reload the page and try again.' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1920
		} else if ( _.isString( response ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1921
			error = response;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1922
		} else if ( 'undefined' !== typeof response.readyState && 0 === response.readyState ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1923
			error = __( 'Connection lost or the server is busy. Please try again later.' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1924
		} else if ( _.isString( response.responseText ) && '' !== response.responseText ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1925
			error = response.responseText;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1926
		} else if ( _.isString( response.statusText ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1927
			error = response.statusText;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1928
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1929
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1930
		switch ( action ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1931
			case 'update':
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1932
				/* translators: %s: Error string for a failed update. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1933
				errorMessage = __( 'Update failed: %s' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1934
				break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1935
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1936
			case 'install':
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1937
				/* translators: %s: Error string for a failed installation. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1938
				errorMessage = __( 'Installation failed: %s' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1939
				break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1940
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1941
			case 'delete':
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1942
				/* translators: %s: Error string for a failed deletion. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1943
				errorMessage = __( 'Deletion failed: %s' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1944
				break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1945
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1946
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1947
		// Messages are escaped, remove HTML tags to make them more readable.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1948
		error = error.replace( /<[\/a-z][^<>]*>/gi, '' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1949
		errorMessage = errorMessage.replace( '%s', error );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1950
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1951
		// Add admin notice.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1952
		wp.updates.addAdminNotice( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1953
			id:        'unknown_error',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1954
			className: 'notice-error is-dismissible',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1955
			message:   _.escape( errorMessage )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1956
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1957
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1958
		// Remove the lock, and clear the queue.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1959
		wp.updates.ajaxLocked = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1960
		wp.updates.queue      = [];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1961
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1962
		// Change buttons of all running updates.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1963
		$( '.button.updating-message' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1964
			.removeClass( 'updating-message' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1965
			.removeAttr( 'aria-label' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1966
			.prop( 'disabled', true )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1967
			.text( __( 'Update failed.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1968
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1969
		$( '.updating-message:not(.button):not(.thickbox)' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1970
			.removeClass( 'updating-message notice-warning' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1971
			.addClass( 'notice-error' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1972
			.find( 'p' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1973
				.removeAttr( 'aria-label' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1974
				.text( errorMessage );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1975
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1976
		wp.a11y.speak( errorMessage, 'assertive' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1977
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1978
		return false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1979
	};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1980
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1981
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1982
	 * Potentially adds an AYS to a user attempting to leave the page.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1983
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1984
	 * If an update is on-going and a user attempts to leave the page,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1985
	 * opens an "Are you sure?" alert.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1986
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1987
	 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1988
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1989
	wp.updates.beforeunload = function() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1990
		if ( wp.updates.ajaxLocked ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1991
			return __( 'Updates may not complete if you navigate away from this page.' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1992
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1993
	};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1994
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1995
	$( function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1996
		var $pluginFilter        = $( '#plugin-filter' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1997
			$bulkActionForm      = $( '#bulk-action-form' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1998
			$filesystemForm      = $( '#request-filesystem-credentials-form' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1999
			$filesystemModal     = $( '#request-filesystem-credentials-dialog' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2000
			$pluginSearch        = $( '.plugins-php .wp-filter-search' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2001
			$pluginInstallSearch = $( '.plugin-install-php .wp-filter-search' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2002
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2003
		settings = _.extend( settings, window._wpUpdatesItemCounts || {} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2004
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2005
		if ( settings.totals ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2006
			wp.updates.refreshCount();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2007
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2008
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2009
		/*
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2010
		 * Whether a user needs to submit filesystem credentials.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2011
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2012
		 * This is based on whether the form was output on the page server-side.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2013
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2014
		 * @see {wp_print_request_filesystem_credentials_modal() in PHP}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2015
		 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2016
		wp.updates.shouldRequestFilesystemCredentials = $filesystemModal.length > 0;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2017
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2018
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2019
		 * File system credentials form submit noop-er / handler.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2020
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2021
		 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2022
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2023
		$filesystemModal.on( 'submit', 'form', function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2024
			event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2025
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2026
			// Persist the credentials input by the user for the duration of the page load.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2027
			wp.updates.filesystemCredentials.ftp.hostname       = $( '#hostname' ).val();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2028
			wp.updates.filesystemCredentials.ftp.username       = $( '#username' ).val();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2029
			wp.updates.filesystemCredentials.ftp.password       = $( '#password' ).val();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2030
			wp.updates.filesystemCredentials.ftp.connectionType = $( 'input[name="connection_type"]:checked' ).val();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2031
			wp.updates.filesystemCredentials.ssh.publicKey      = $( '#public_key' ).val();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2032
			wp.updates.filesystemCredentials.ssh.privateKey     = $( '#private_key' ).val();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2033
			wp.updates.filesystemCredentials.fsNonce            = $( '#_fs_nonce' ).val();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2034
			wp.updates.filesystemCredentials.available          = true;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2035
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2036
			// Unlock and invoke the queue.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2037
			wp.updates.ajaxLocked = false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2038
			wp.updates.queueChecker();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2039
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2040
			wp.updates.requestForCredentialsModalClose();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2041
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2042
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2043
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2044
		 * Closes the request credentials modal when clicking the 'Cancel' button or outside of the modal.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2045
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2046
		 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2047
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2048
		$filesystemModal.on( 'click', '[data-js-action="close"], .notification-dialog-background', wp.updates.requestForCredentialsModalCancel );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2049
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2050
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2051
		 * Hide SSH fields when not selected.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2052
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2053
		 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2054
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2055
		$filesystemForm.on( 'change', 'input[name="connection_type"]', function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2056
			$( '#ssh-keys' ).toggleClass( 'hidden', ( 'ssh' !== $( this ).val() ) );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2057
		} ).trigger( 'change' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2058
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2059
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2060
		 * Handles events after the credential modal was closed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2061
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2062
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2063
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2064
		 * @param {Event}  event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2065
		 * @param {string} job   The install/update.delete request.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2066
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2067
		$document.on( 'credential-modal-cancel', function( event, job ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2068
			var $updatingMessage = $( '.updating-message' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2069
				$message, originalText;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2070
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2071
			if ( 'import' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2072
				$updatingMessage.removeClass( 'updating-message' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2073
			} else if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2074
				if ( 'update-plugin' === job.action ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2075
					$message = $( 'tr[data-plugin="' + job.data.plugin + '"]' ).find( '.update-message' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2076
				} else if ( 'delete-plugin' === job.action ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2077
					$message = $( '[data-plugin="' + job.data.plugin + '"]' ).find( '.row-actions a.delete' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2078
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2079
			} else if ( 'themes' === pagenow || 'themes-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2080
				if ( 'update-theme' === job.action ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2081
					$message = $( '[data-slug="' + job.data.slug + '"]' ).find( '.update-message' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2082
				} else if ( 'delete-theme' === job.action && 'themes-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2083
					$message = $( '[data-slug="' + job.data.slug + '"]' ).find( '.row-actions a.delete' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2084
				} else if ( 'delete-theme' === job.action && 'themes' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2085
					$message = $( '.theme-actions .delete-theme' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2086
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2087
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2088
				$message = $updatingMessage;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2089
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2090
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2091
			if ( $message && $message.hasClass( 'updating-message' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2092
				originalText = $message.data( 'originaltext' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2093
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2094
				if ( 'undefined' === typeof originalText ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2095
					originalText = $( '<p>' ).html( $message.find( 'p' ).data( 'originaltext' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2096
				}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2097
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2098
				$message
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2099
					.removeClass( 'updating-message' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2100
					.html( originalText );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2101
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2102
				if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2103
					if ( 'update-plugin' === job.action ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2104
						$message.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2105
							'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2106
							sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2107
								/* translators: %s: Plugin name and version. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2108
								_x( 'Update %s now', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2109
								$message.data( 'name' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2110
							)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2111
						);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2112
					} else if ( 'install-plugin' === job.action ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2113
						$message.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2114
							'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2115
							sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2116
								/* translators: %s: Plugin name. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2117
								_x( 'Install %s now', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2118
								$message.data( 'name' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2119
							)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2120
						);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2121
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2122
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2123
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2124
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2125
			wp.a11y.speak( __( 'Update canceled.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2126
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2127
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2128
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2129
		 * Click handler for plugin updates in List Table view.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2130
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2131
		 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2132
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2133
		 * @param {Event} event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2134
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2135
		$bulkActionForm.on( 'click', '[data-plugin] .update-link', function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2136
			var $message   = $( event.target ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2137
				$pluginRow = $message.parents( 'tr' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2138
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2139
			event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2140
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2141
			if ( $message.hasClass( 'updating-message' ) || $message.hasClass( 'button-disabled' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2142
				return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2143
			}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2144
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2145
			wp.updates.maybeRequestFilesystemCredentials( event );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2146
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2147
			// Return the user to the input box of the plugin's table row after closing the modal.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2148
			wp.updates.$elToReturnFocusToFromCredentialsModal = $pluginRow.find( '.check-column input' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2149
			wp.updates.updatePlugin( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2150
				plugin: $pluginRow.data( 'plugin' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2151
				slug:   $pluginRow.data( 'slug' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2152
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2153
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2154
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2155
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2156
		 * Click handler for plugin updates in plugin install view.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2157
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2158
		 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2159
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2160
		 * @param {Event} event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2161
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2162
		$pluginFilter.on( 'click', '.update-now', function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2163
			var $button = $( event.target );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2164
			event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2165
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2166
			if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2167
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2168
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2169
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2170
			wp.updates.maybeRequestFilesystemCredentials( event );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2171
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2172
			wp.updates.updatePlugin( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2173
				plugin: $button.data( 'plugin' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2174
				slug:   $button.data( 'slug' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2175
			} );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2176
		} );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2177
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2178
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2179
		 * Click handler for plugin installs in plugin install view.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2180
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2181
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2182
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2183
		 * @param {Event} event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2184
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2185
		$pluginFilter.on( 'click', '.install-now', function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2186
			var $button = $( event.target );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2187
			event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2188
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2189
			if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2190
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2191
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2192
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2193
			if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2194
				wp.updates.requestFilesystemCredentials( event );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2195
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2196
				$document.on( 'credential-modal-cancel', function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2197
					var $message = $( '.install-now.updating-message' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2198
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2199
					$message
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2200
						.removeClass( 'updating-message' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2201
						.text( __( 'Install Now' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2202
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2203
					wp.a11y.speak( __( 'Update canceled.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2204
				} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2205
			}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2206
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2207
			wp.updates.installPlugin( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2208
				slug: $button.data( 'slug' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2209
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2210
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2211
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2212
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2213
		 * Click handler for importer plugins installs in the Import screen.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2214
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2215
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2216
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2217
		 * @param {Event} event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2218
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2219
		$document.on( 'click', '.importer-item .install-now', function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2220
			var $button = $( event.target ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2221
				pluginName = $( this ).data( 'name' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2222
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2223
			event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2224
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2225
			if ( $button.hasClass( 'updating-message' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2226
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2227
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2228
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2229
			if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2230
				wp.updates.requestFilesystemCredentials( event );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2231
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2232
				$document.on( 'credential-modal-cancel', function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2233
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2234
					$button
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2235
						.removeClass( 'updating-message' )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2236
						.attr(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2237
							'aria-label',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2238
							sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2239
								/* translators: %s: Plugin name. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2240
								_x( 'Install %s now', 'plugin' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2241
								pluginName
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2242
							)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2243
						)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2244
						.text( __( 'Install Now' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2245
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2246
					wp.a11y.speak( __( 'Update canceled.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2247
				} );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2248
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2249
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2250
			wp.updates.installPlugin( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2251
				slug:    $button.data( 'slug' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2252
				pagenow: pagenow,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2253
				success: wp.updates.installImporterSuccess,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2254
				error:   wp.updates.installImporterError
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2255
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2256
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2257
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2258
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2259
		 * Click handler for plugin deletions.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2260
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2261
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2262
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2263
		 * @param {Event} event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2264
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2265
		$bulkActionForm.on( 'click', '[data-plugin] a.delete', function( event ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2266
			var $pluginRow = $( event.target ).parents( 'tr' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2267
				confirmMessage;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2268
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2269
			if ( $pluginRow.hasClass( 'is-uninstallable' ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2270
				confirmMessage = sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2271
					/* translators: %s: Plugin name. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2272
					__( 'Are you sure you want to delete %s and its data?' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2273
					$pluginRow.find( '.plugin-title strong' ).text()
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2274
				);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2275
			} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2276
				confirmMessage = sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2277
					/* translators: %s: Plugin name. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2278
					__( 'Are you sure you want to delete %s?' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2279
					$pluginRow.find( '.plugin-title strong' ).text()
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2280
				);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2281
			}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2282
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2283
			event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2284
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2285
			if ( ! window.confirm( confirmMessage ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2286
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2287
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2288
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2289
			wp.updates.maybeRequestFilesystemCredentials( event );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2290
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2291
			wp.updates.deletePlugin( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2292
				plugin: $pluginRow.data( 'plugin' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2293
				slug:   $pluginRow.data( 'slug' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2294
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2295
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2296
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2297
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2298
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2299
		 * Click handler for theme updates.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2300
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2301
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2302
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2303
		 * @param {Event} event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2304
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2305
		$document.on( 'click', '.themes-php.network-admin .update-link', function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2306
			var $message  = $( event.target ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2307
				$themeRow = $message.parents( 'tr' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2308
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2309
			event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2310
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2311
			if ( $message.hasClass( 'updating-message' ) || $message.hasClass( 'button-disabled' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2312
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2313
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2314
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2315
			wp.updates.maybeRequestFilesystemCredentials( event );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2316
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2317
			// Return the user to the input box of the theme's table row after closing the modal.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2318
			wp.updates.$elToReturnFocusToFromCredentialsModal = $themeRow.find( '.check-column input' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2319
			wp.updates.updateTheme( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2320
				slug: $themeRow.data( 'slug' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2321
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2322
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2323
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2324
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2325
		 * Click handler for theme deletions.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2326
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2327
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2328
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2329
		 * @param {Event} event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2330
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2331
		$document.on( 'click', '.themes-php.network-admin a.delete', function( event ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2332
			var $themeRow = $( event.target ).parents( 'tr' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2333
				confirmMessage = sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2334
					/* translators: %s: Theme name. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2335
					__( 'Are you sure you want to delete %s?' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2336
					$themeRow.find( '.theme-title strong' ).text()
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2337
				);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2338
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2339
			event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2340
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2341
			if ( ! window.confirm( confirmMessage ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2342
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2343
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2344
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2345
			wp.updates.maybeRequestFilesystemCredentials( event );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2346
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2347
			wp.updates.deleteTheme( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2348
				slug: $themeRow.data( 'slug' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2349
			} );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2350
		} );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2351
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2352
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2353
		 * Bulk action handler for plugins and themes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2354
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2355
		 * Handles both deletions and updates.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2356
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2357
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2358
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2359
		 * @param {Event} event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2360
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2361
		$bulkActionForm.on( 'click', '[type="submit"]:not([name="clear-recent-list"])', function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2362
			var bulkAction    = $( event.target ).siblings( 'select' ).val(),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2363
				itemsSelected = $bulkActionForm.find( 'input[name="checked[]"]:checked' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2364
				success       = 0,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2365
				error         = 0,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2366
				errorMessages = [],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2367
				type, action;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2368
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2369
			// Determine which type of item we're dealing with.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2370
			switch ( pagenow ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2371
				case 'plugins':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2372
				case 'plugins-network':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2373
					type = 'plugin';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2374
					break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2375
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2376
				case 'themes-network':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2377
					type = 'theme';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2378
					break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2379
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2380
				default:
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2381
					return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2382
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2383
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2384
			// Bail if there were no items selected.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2385
			if ( ! itemsSelected.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2386
				event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2387
				$( 'html, body' ).animate( { scrollTop: 0 } );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2388
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2389
				return wp.updates.addAdminNotice( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2390
					id:        'no-items-selected',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2391
					className: 'notice-error is-dismissible',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2392
					message:   __( 'Please select at least one item to perform this action on.' )
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2393
				} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2394
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2395
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2396
			// Determine the type of request we're dealing with.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2397
			switch ( bulkAction ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2398
				case 'update-selected':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2399
					action = bulkAction.replace( 'selected', type );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2400
					break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2401
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2402
				case 'delete-selected':
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2403
					var confirmMessage = 'plugin' === type ?
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2404
						__( 'Are you sure you want to delete the selected plugins and their data?' ) :
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2405
						__( 'Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2406
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2407
					if ( ! window.confirm( confirmMessage ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2408
						event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2409
						return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2410
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2411
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2412
					action = bulkAction.replace( 'selected', type );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2413
					break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2414
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2415
				default:
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2416
					return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2417
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2418
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2419
			wp.updates.maybeRequestFilesystemCredentials( event );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2420
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2421
			event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2422
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2423
			// Un-check the bulk checkboxes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2424
			$bulkActionForm.find( '.manage-column [type="checkbox"]' ).prop( 'checked', false );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2425
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2426
			$document.trigger( 'wp-' + type + '-bulk-' + bulkAction, itemsSelected );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2427
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2428
			// Find all the checkboxes which have been checked.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2429
			itemsSelected.each( function( index, element ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2430
				var $checkbox = $( element ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2431
					$itemRow = $checkbox.parents( 'tr' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2432
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2433
				// Only add update-able items to the update queue.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2434
				if ( 'update-selected' === bulkAction && ( ! $itemRow.hasClass( 'update' ) || $itemRow.find( 'notice-error' ).length ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2435
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2436
					// Un-check the box.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2437
					$checkbox.prop( 'checked', false );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2438
					return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2439
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2440
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2441
				// Add it to the queue.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2442
				wp.updates.queue.push( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2443
					action: action,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2444
					data:   {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2445
						plugin: $itemRow.data( 'plugin' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2446
						slug:   $itemRow.data( 'slug' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2447
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2448
				} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2449
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2450
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2451
			// Display bulk notification for updates of any kind.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2452
			$document.on( 'wp-plugin-update-success wp-plugin-update-error wp-theme-update-success wp-theme-update-error', function( event, response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2453
				var $itemRow = $( '[data-slug="' + response.slug + '"]' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2454
					$bulkActionNotice, itemName;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2455
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2456
				if ( 'wp-' + response.update + '-update-success' === event.type ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2457
					success++;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2458
				} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2459
					itemName = response.pluginName ? response.pluginName : $itemRow.find( '.column-primary strong' ).text();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2460
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2461
					error++;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2462
					errorMessages.push( itemName + ': ' + response.errorMessage );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2463
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2464
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2465
				$itemRow.find( 'input[name="checked[]"]:checked' ).prop( 'checked', false );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2466
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2467
				wp.updates.adminNotice = wp.template( 'wp-bulk-updates-admin-notice' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2468
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2469
				wp.updates.addAdminNotice( {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2470
					id:            'bulk-action-notice',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2471
					className:     'bulk-action-notice',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2472
					successes:     success,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2473
					errors:        error,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2474
					errorMessages: errorMessages,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2475
					type:          response.update
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2476
				} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2477
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2478
				$bulkActionNotice = $( '#bulk-action-notice' ).on( 'click', 'button', function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2479
					// $( this ) is the clicked button, no need to get it again.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2480
					$( this )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2481
						.toggleClass( 'bulk-action-errors-collapsed' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2482
						.attr( 'aria-expanded', ! $( this ).hasClass( 'bulk-action-errors-collapsed' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2483
					// Show the errors list.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2484
					$bulkActionNotice.find( '.bulk-action-errors' ).toggleClass( 'hidden' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2485
				} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2486
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2487
				if ( error > 0 && ! wp.updates.queue.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2488
					$( 'html, body' ).animate( { scrollTop: 0 } );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2489
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2490
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2491
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2492
			// Reset admin notice template after #bulk-action-notice was added.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2493
			$document.on( 'wp-updates-notice-added', function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2494
				wp.updates.adminNotice = wp.template( 'wp-updates-admin-notice' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2495
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2496
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2497
			// Check the queue, now that the event handlers have been added.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2498
			wp.updates.queueChecker();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2499
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2500
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2501
		if ( $pluginInstallSearch.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2502
			$pluginInstallSearch.attr( 'aria-describedby', 'live-search-desc' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2503
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2504
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2505
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2506
		 * Handles changes to the plugin search box on the new-plugin page,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2507
		 * searching the repository dynamically.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2508
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2509
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2510
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2511
		$pluginInstallSearch.on( 'keyup input', _.debounce( function( event, eventtype ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2512
			var $searchTab = $( '.plugin-install-search' ), data, searchLocation;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2513
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2514
			data = {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2515
				_ajax_nonce: wp.updates.ajaxNonce,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2516
				s:           event.target.value,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2517
				tab:         'search',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2518
				type:        $( '#typeselector' ).val(),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2519
				pagenow:     pagenow
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2520
			};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2521
			searchLocation = location.href.split( '?' )[ 0 ] + '?' + $.param( _.omit( data, [ '_ajax_nonce', 'pagenow' ] ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2522
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2523
			// Clear on escape.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2524
			if ( 'keyup' === event.type && 27 === event.which ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2525
				event.target.value = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2526
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2527
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2528
			if ( wp.updates.searchTerm === data.s && 'typechange' !== eventtype ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2529
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2530
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2531
				$pluginFilter.empty();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2532
				wp.updates.searchTerm = data.s;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2533
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2534
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2535
			if ( window.history && window.history.replaceState ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2536
				window.history.replaceState( null, '', searchLocation );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2537
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2538
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2539
			if ( ! $searchTab.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2540
				$searchTab = $( '<li class="plugin-install-search" />' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2541
					.append( $( '<a />', {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2542
						'class': 'current',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2543
						'href': searchLocation,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2544
						'text': __( 'Search Results' )
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2545
					} ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2546
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2547
				$( '.wp-filter .filter-links .current' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2548
					.removeClass( 'current' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2549
					.parents( '.filter-links' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2550
					.prepend( $searchTab );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2551
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2552
				$pluginFilter.prev( 'p' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2553
				$( '.plugins-popular-tags-wrapper' ).remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2554
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2555
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2556
			if ( 'undefined' !== typeof wp.updates.searchRequest ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2557
				wp.updates.searchRequest.abort();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2558
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2559
			$( 'body' ).addClass( 'loading-content' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2560
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2561
			wp.updates.searchRequest = wp.ajax.post( 'search-install-plugins', data ).done( function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2562
				$( 'body' ).removeClass( 'loading-content' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2563
				$pluginFilter.append( response.items );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2564
				delete wp.updates.searchRequest;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2565
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2566
				if ( 0 === response.count ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2567
					wp.a11y.speak( __( 'You do not appear to have any plugins available at this time.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2568
				} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2569
					wp.a11y.speak(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2570
						sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2571
							/* translators: %s: Number of plugins. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2572
							__( 'Number of plugins found: %d' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2573
							response.count
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2574
						)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2575
					);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2576
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2577
			} );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2578
		}, 1000 ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2579
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2580
		if ( $pluginSearch.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2581
			$pluginSearch.attr( 'aria-describedby', 'live-search-desc' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2582
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2583
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2584
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2585
		 * Handles changes to the plugin search box on the Installed Plugins screen,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2586
		 * searching the plugin list dynamically.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2587
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2588
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2589
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2590
		$pluginSearch.on( 'keyup input', _.debounce( function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2591
			var data = {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2592
				_ajax_nonce:   wp.updates.ajaxNonce,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2593
				s:             event.target.value,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2594
				pagenow:       pagenow,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2595
				plugin_status: 'all'
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2596
			},
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2597
			queryArgs;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2598
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2599
			// Clear on escape.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2600
			if ( 'keyup' === event.type && 27 === event.which ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2601
				event.target.value = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2602
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2603
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2604
			if ( wp.updates.searchTerm === data.s ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2605
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2606
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2607
				wp.updates.searchTerm = data.s;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2608
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2609
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2610
			queryArgs = _.object( _.compact( _.map( location.search.slice( 1 ).split( '&' ), function( item ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2611
				if ( item ) return item.split( '=' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2612
			} ) ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2613
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2614
			data.plugin_status = queryArgs.plugin_status || 'all';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2615
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2616
			if ( window.history && window.history.replaceState ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2617
				window.history.replaceState( null, '', location.href.split( '?' )[ 0 ] + '?s=' + data.s + '&plugin_status=' + data.plugin_status );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2618
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2619
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2620
			if ( 'undefined' !== typeof wp.updates.searchRequest ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2621
				wp.updates.searchRequest.abort();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2622
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2623
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2624
			$bulkActionForm.empty();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2625
			$( 'body' ).addClass( 'loading-content' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2626
			$( '.subsubsub .current' ).removeClass( 'current' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2627
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2628
			wp.updates.searchRequest = wp.ajax.post( 'search-plugins', data ).done( function( response ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2629
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2630
				// Can we just ditch this whole subtitle business?
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2631
				var $subTitle    = $( '<span />' ).addClass( 'subtitle' ).html(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2632
					sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2633
						/* translators: %s: Search query. */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2634
						__( 'Search results for: %s' ),
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2635
						'<strong>' + _.escape( data.s ) + '</strong>'
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2636
					) ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2637
					$oldSubTitle = $( '.wrap .subtitle' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2638
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2639
				if ( ! data.s.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2640
					$oldSubTitle.remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2641
					$( '.subsubsub .' + data.plugin_status + ' a' ).addClass( 'current' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2642
				} else if ( $oldSubTitle.length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2643
					$oldSubTitle.replaceWith( $subTitle );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2644
				} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2645
					$( '.wp-header-end' ).before( $subTitle );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2646
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2647
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2648
				$( 'body' ).removeClass( 'loading-content' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2649
				$bulkActionForm.append( response.items );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2650
				delete wp.updates.searchRequest;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2651
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2652
				if ( 0 === response.count ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2653
					wp.a11y.speak( __( 'No plugins found. Try a different search.'  ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2654
				} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2655
					wp.a11y.speak(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2656
						sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2657
							/* translators: %s: Number of plugins. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2658
							__( 'Number of plugins found: %d' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2659
							response.count
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2660
						)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2661
					);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2662
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2663
			} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2664
		}, 500 ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2665
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2666
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2667
		 * Trigger a search event when the search form gets submitted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2668
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2669
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2670
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2671
		$document.on( 'submit', '.search-plugins', function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2672
			event.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2673
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2674
			$( 'input.wp-filter-search' ).trigger( 'input' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2675
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2676
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2677
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2678
		 * Trigger a search event when the "Try Again" button is clicked.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2679
		 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2680
		 * @since 4.9.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2681
		 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2682
		$document.on( 'click', '.try-again', function( event ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2683
			event.preventDefault();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2684
			$pluginInstallSearch.trigger( 'input' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2685
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2686
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2687
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2688
		 * Trigger a search event when the search type gets changed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2689
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2690
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2691
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2692
		$( '#typeselector' ).on( 'change', function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2693
			var $search = $( 'input[name="s"]' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2694
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2695
			if ( $search.val().length ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2696
				$search.trigger( 'input', 'typechange' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2697
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2698
		} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2699
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2700
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2701
		 * Click handler for updating a plugin from the details modal on `plugin-install.php`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2702
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2703
		 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2704
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2705
		 * @param {Event} event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2706
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2707
		$( '#plugin_update_from_iframe' ).on( 'click', function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2708
			var target = window.parent === window ? null : window.parent,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2709
				update;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2710
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2711
			$.support.postMessage = !! window.postMessage;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2712
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2713
			if ( false === $.support.postMessage || null === target || -1 !== window.parent.location.pathname.indexOf( 'update-core.php' ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2714
				return;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2715
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2716
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2717
			event.preventDefault();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2718
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2719
			update = {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2720
				action: 'update-plugin',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2721
				data:   {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2722
					plugin: $( this ).data( 'plugin' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2723
					slug:   $( this ).data( 'slug' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2724
				}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2725
			};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2726
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2727
			target.postMessage( JSON.stringify( update ), window.location.origin );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2728
		} );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2729
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2730
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2731
		 * Click handler for installing a plugin from the details modal on `plugin-install.php`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2732
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2733
		 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2734
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2735
		 * @param {Event} event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2736
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2737
		$( '#plugin_install_from_iframe' ).on( 'click', function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2738
			var target = window.parent === window ? null : window.parent,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2739
				install;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2740
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2741
			$.support.postMessage = !! window.postMessage;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2742
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2743
			if ( false === $.support.postMessage || null === target || -1 !== window.parent.location.pathname.indexOf( 'index.php' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2744
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2745
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2746
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2747
			event.preventDefault();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2748
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2749
			install = {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2750
				action: 'install-plugin',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2751
				data:   {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2752
					slug: $( this ).data( 'slug' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2753
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2754
			};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2755
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2756
			target.postMessage( JSON.stringify( install ), window.location.origin );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2757
		} );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2758
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2759
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2760
		 * Handles postMessage events.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2761
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2762
		 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2763
		 * @since 4.6.0 Switched `update-plugin` action to use the queue.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2764
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2765
		 * @param {Event} event Event interface.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2766
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2767
		$( window ).on( 'message', function( event ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2768
			var originalEvent  = event.originalEvent,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2769
				expectedOrigin = document.location.protocol + '//' + document.location.host,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2770
				message;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2771
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2772
			if ( originalEvent.origin !== expectedOrigin ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2773
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2774
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2775
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2776
			try {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2777
				message = JSON.parse( originalEvent.data );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2778
			} catch ( e ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2779
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2780
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2781
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2782
			if ( ! message || 'undefined' === typeof message.action ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2783
				return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2784
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2785
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2786
			switch ( message.action ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2787
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2788
				// Called from `wp-admin/includes/class-wp-upgrader-skins.php`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2789
				case 'decrementUpdateCount':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2790
					/** @property {string} message.upgradeType */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2791
					wp.updates.decrementCount( message.upgradeType );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2792
					break;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2793
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2794
				case 'install-plugin':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2795
				case 'update-plugin':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2796
					/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2797
					window.tb_remove();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2798
					/* jscs:enable */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2799
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2800
					message.data = wp.updates._addCallbacks( message.data, message.action );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2801
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2802
					wp.updates.queue.push( message );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2803
					wp.updates.queueChecker();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2804
					break;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2805
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2806
		} );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2807
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2808
		/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2809
		 * Adds a callback to display a warning before leaving the page.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2810
		 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2811
		 * @since 4.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2812
		 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2813
		$( window ).on( 'beforeunload', wp.updates.beforeunload );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2814
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2815
		/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2816
		 * Prevents the page form scrolling when activating auto-updates with the Spacebar key.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2817
		 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2818
		 * @since 5.5.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2819
		 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2820
		$document.on( 'keydown', '.column-auto-updates .toggle-auto-update, .theme-overlay .toggle-auto-update', function( event ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2821
			if ( 32 === event.which ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2822
				event.preventDefault();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2823
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2824
		} );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2825
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2826
		/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2827
		 * Click and keyup handler for enabling and disabling plugin and theme auto-updates.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2828
		 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2829
		 * These controls can be either links or buttons. When JavaScript is enabled,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2830
		 * we want them to behave like buttons. An ARIA role `button` is added via
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2831
		 * the JavaScript that targets elements with the CSS class `aria-button-if-js`.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2832
		 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2833
		 * @since 5.5.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2834
		 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2835
		$document.on( 'click keyup', '.column-auto-updates .toggle-auto-update, .theme-overlay .toggle-auto-update', function( event ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2836
			var data, asset, type, $parent,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2837
				$toggler = $( this ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2838
				action = $toggler.attr( 'data-wp-action' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2839
				$label = $toggler.find( '.label' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2840
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2841
			if ( 'keyup' === event.type && 32 !== event.which ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2842
				return;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2843
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2844
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2845
			if ( 'themes' !== pagenow ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2846
				$parent = $toggler.closest( '.column-auto-updates' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2847
			} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2848
				$parent = $toggler.closest( '.theme-autoupdate' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2849
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2850
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2851
			event.preventDefault();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2852
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2853
			// Prevent multiple simultaneous requests.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2854
			if ( $toggler.attr( 'data-doing-ajax' ) === 'yes' ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2855
				return;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2856
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2857
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2858
			$toggler.attr( 'data-doing-ajax', 'yes' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2859
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2860
			switch ( pagenow ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2861
				case 'plugins':
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2862
				case 'plugins-network':
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2863
					type = 'plugin';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2864
					asset = $toggler.closest( 'tr' ).attr( 'data-plugin' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2865
					break;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2866
				case 'themes-network':
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2867
					type = 'theme';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2868
					asset = $toggler.closest( 'tr' ).attr( 'data-slug' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2869
					break;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2870
				case 'themes':
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2871
					type = 'theme';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2872
					asset = $toggler.attr( 'data-slug' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2873
					break;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2874
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2875
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2876
			// Clear any previous errors.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2877
			$parent.find( '.notice.notice-error' ).addClass( 'hidden' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2878
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2879
			// Show loading status.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2880
			if ( 'enable' === action ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2881
				$label.text( __( 'Enabling...' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2882
			} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2883
				$label.text( __( 'Disabling...' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2884
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2885
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2886
			$toggler.find( '.dashicons-update' ).removeClass( 'hidden' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2887
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2888
			data = {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2889
				action: 'toggle-auto-updates',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2890
				_ajax_nonce: settings.ajax_nonce,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2891
				state: action,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2892
				type: type,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2893
				asset: asset
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2894
			};
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2895
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2896
			$.post( window.ajaxurl, data )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2897
				.done( function( response ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2898
					var $enabled, $disabled, enabledNumber, disabledNumber, errorMessage,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2899
						href = $toggler.attr( 'href' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2900
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2901
					if ( ! response.success ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2902
						// if WP returns 0 for response (which can happen in a few cases),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2903
						// output the general error message since we won't have response.data.error.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2904
						if ( response.data && response.data.error ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2905
							errorMessage = response.data.error;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2906
						} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2907
							errorMessage = __( 'The request could not be completed.' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2908
						}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2909
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2910
						$parent.find( '.notice.notice-error' ).removeClass( 'hidden' ).find( 'p' ).text( errorMessage );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2911
						wp.a11y.speak( errorMessage, 'assertive' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2912
						return;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2913
					}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2914
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2915
					// Update the counts in the enabled/disabled views if on a screen
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2916
					// with a list table.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2917
					if ( 'themes' !== pagenow ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2918
						$enabled       = $( '.auto-update-enabled span' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2919
						$disabled      = $( '.auto-update-disabled span' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2920
						enabledNumber  = parseInt( $enabled.text().replace( /[^\d]+/g, '' ), 10 ) || 0;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2921
						disabledNumber = parseInt( $disabled.text().replace( /[^\d]+/g, '' ), 10 ) || 0;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2922
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2923
						switch ( action ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2924
							case 'enable':
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2925
								++enabledNumber;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2926
								--disabledNumber;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2927
								break;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2928
							case 'disable':
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2929
								--enabledNumber;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2930
								++disabledNumber;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2931
								break;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2932
						}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2933
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2934
						enabledNumber = Math.max( 0, enabledNumber );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2935
						disabledNumber = Math.max( 0, disabledNumber );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2936
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2937
						$enabled.text( '(' + enabledNumber + ')' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2938
						$disabled.text( '(' + disabledNumber + ')' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2939
					}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2940
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2941
					if ( 'enable' === action ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2942
						// The toggler control can be either a link or a button.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2943
						if ( $toggler[ 0 ].hasAttribute( 'href' ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2944
							href = href.replace( 'action=enable-auto-update', 'action=disable-auto-update' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2945
							$toggler.attr( 'href', href );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2946
						}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2947
						$toggler.attr( 'data-wp-action', 'disable' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2948
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2949
						$label.text( __( 'Disable auto-updates' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2950
						$parent.find( '.auto-update-time' ).removeClass( 'hidden' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2951
						wp.a11y.speak( __( 'Auto-updates enabled' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2952
					} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2953
						// The toggler control can be either a link or a button.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2954
						if ( $toggler[ 0 ].hasAttribute( 'href' ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2955
							href = href.replace( 'action=disable-auto-update', 'action=enable-auto-update' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2956
							$toggler.attr( 'href', href );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2957
						}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2958
						$toggler.attr( 'data-wp-action', 'enable' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2959
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2960
						$label.text( __( 'Enable auto-updates' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2961
						$parent.find( '.auto-update-time' ).addClass( 'hidden' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2962
						wp.a11y.speak( __( 'Auto-updates disabled' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2963
					}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2964
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2965
					$document.trigger( 'wp-auto-update-setting-changed', { state: action, type: type, asset: asset } );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2966
				} )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2967
				.fail( function() {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2968
					$parent.find( '.notice.notice-error' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2969
						.removeClass( 'hidden' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2970
						.find( 'p' )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2971
						.text( __( 'The request could not be completed.' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2972
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2973
					wp.a11y.speak( __( 'The request could not be completed.' ), 'assertive' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2974
				} )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2975
				.always( function() {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2976
					$toggler.removeAttr( 'data-doing-ajax' ).find( '.dashicons-update' ).addClass( 'hidden' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2977
				} );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2978
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2979
		);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2980
	} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2981
})( jQuery, window.wp, window._wpUpdatesSettings );