Skip to content

Commit b406738

Browse files
authored
Merge pull request #218 from Ultimate-Multisite/create-network-wiz
WIP Create network wiz
2 parents 8bfb181 + d790a28 commit b406738

38 files changed

Lines changed: 1247 additions & 266 deletions

.phpcs.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<arg name="colors"/>
1818
<arg name="extensions" value="php"/>
1919
<arg name="parallel" value="8"/><!-- Enables parallel processing when available for faster results. -->
20-
2120
<!-- Rules: Check PHP version compatibility -->
2221
<!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
2322
<config name="testVersion" value="7.4-"/>

.wiki/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The documentation is organized into the following categories:
1818

1919
## How to Use This Documentation
2020

21-
You can browse the documentation directly on GitHub by visiting the [Wiki](https://github.com/superdav42/wp-multisite-waas/wiki).
21+
You can browse the documentation at [ultimatemultisite.com/docs](https://ultimatemultisite.com/docs/).
2222

2323
### Automatic Sync
2424

assets/js/setup-wizard.js

Lines changed: 139 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,212 +1,218 @@
11
/* global wu_setup, wu_setup_settings, ajaxurl, wu_block_ui_polyfill, _wu_block_ui_polyfill */
22
(function($) {
33

4-
window._wu_block_ui_polyfill = wu_block_ui_polyfill;
4+
window._wu_block_ui_polyfill = wu_block_ui_polyfill;
55

6-
wu_block_ui_polyfill = function() { };
6+
wu_block_ui_polyfill = function() { };
77

8-
$(document).ready(function() {
8+
$(document).ready(function() {
99

10-
// Click button
11-
// Generates queue
12-
// Start to process queue items one by one
13-
// Changes the status
14-
// Move to the next item
15-
// When all is done, redirect to the next page via a form submission
16-
$('#poststuff').on('submit', 'form', function(e) {
10+
// Click button
11+
// Generates queue
12+
// Start to process queue items one by one
13+
// Changes the status
14+
// Move to the next item
15+
// When all is done, redirect to the next page via a form submission
16+
$('#poststuff').on('submit', 'form', function(e) {
1717

18-
e.preventDefault();
18+
e.preventDefault();
1919

20-
const $form = $(this);
20+
const $form = $(this);
2121

22-
const install_id = $form.find('table[data-id]').data('id');
22+
const install_id = $form.find('table[data-id]').data('id');
2323

24-
$form.find('[name=next]').attr('disabled', 'disabled');
24+
$form.find('[name=next]').attr('disabled', 'disabled');
2525

26-
let queue = $form.find('tr[data-content]');
26+
let queue = $form.find('tr[data-content]');
2727

28-
/*
28+
/*
2929
* Only keep items selected on the queue.
3030
*/
31-
queue = queue.filter(function() {
31+
queue = queue.filter(function() {
3232

33-
const checkbox = $(this).find('input[type=checkbox]');
33+
const checkbox = $(this).find('input[type=checkbox]');
3434

35-
if (checkbox.length) {
35+
if (checkbox.length) {
3636

37-
return checkbox.is(':checked');
37+
return checkbox.is(':checked');
3838

39-
} // end if;
39+
} // end if;
4040

41-
return true;
41+
return true;
4242

43-
});
43+
});
4444

45-
let successes = 0;
45+
let successes = 0;
4646

47-
let index = 0;
47+
let index = 0;
4848

49-
process_queue_item(queue.eq(index));
49+
process_queue_item(queue.eq(index));
5050

51-
/**
52-
* Process the queue items one by one recursively.
53-
*
54-
* @param {string} item The item to process.
55-
*/
56-
function process_queue_item(item) {
51+
/**
52+
* Process the queue items one by one recursively.
53+
*
54+
* @param {string} item The item to process.
55+
*/
56+
function process_queue_item(item) {
57+
58+
window.onbeforeunload = function() {
59+
60+
return '';
5761

58-
window.onbeforeunload = function() {
62+
};
5963

60-
return '';
64+
if (item.length === 0) {
6165

62-
};
66+
if (queue.length === successes || install_id === 'migration') {
6367

64-
if (item.length === 0) {
68+
window.onbeforeunload = null;
6569

66-
if (queue.length === successes || install_id === 'migration') {
70+
_wu_block_ui_polyfill($('#poststuff .inside'));
6771

68-
window.onbeforeunload = null;
72+
setTimeout(() => {
6973

70-
_wu_block_ui_polyfill($('#poststuff .inside'));
74+
$form.get(0).submit();
7175

72-
setTimeout(() => {
76+
}, 100);
7377

74-
$form.get(0).submit();
78+
} // end if;
7579

76-
}, 100);
80+
$form.find('[name=next]').removeAttr('disabled');
7781

78-
} // end if;
82+
return false;
7983

80-
$form.find('[name=next]').removeAttr('disabled');
84+
} // end if;
8185

82-
return false;
86+
const $item = $(item);
8387

84-
} // end if;
88+
const content = $item.data('content');
8589

86-
const $item = $(item);
90+
$item.get(0).scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });
8791

88-
const content = $item.data('content');
92+
$item.find('td.status')
93+
.attr('class', '')
94+
.addClass('status')
95+
.find('> span').html(wu_setup[ content ].installing).end()
96+
.find('.spinner').addClass('is-active').end()
97+
.find('a.help').slideUp();
8998

90-
$item.get(0).scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });
99+
// Ajax request
100+
$.ajax({
101+
url: ajaxurl,
102+
method: 'post',
103+
data: {
104+
action: wu_setup_settings.ajax_action || 'wu_setup_install',
105+
installer: content,
106+
'dry-run': wu_setup_settings.dry_run,
107+
},
108+
success(data) {
91109

92-
$item.find('td.status')
93-
.attr('class', '')
94-
.addClass('status')
95-
.find('> span').html(wu_setup[content].installing).end()
96-
.find('.spinner').addClass('is-active').end()
97-
.find('a.help').slideUp();
110+
if (data.success === true) {
98111

99-
// Ajax request
100-
$.ajax({
101-
url: ajaxurl,
102-
method: 'post',
103-
data: {
104-
action: 'wu_setup_install',
105-
installer: content,
106-
'dry-run': wu_setup_settings.dry_run,
107-
},
108-
success(data) {
112+
$item.find('td.status')
113+
.attr('class', '')
114+
.addClass('status wu-text-green-600')
115+
.find('> span').html(wu_setup[ content ].success).end()
116+
.find('.spinner').removeClass('is-active');
109117

110-
if (data.success === true) {
118+
$item.removeAttr('data-content');
111119

112-
$item.find('td.status')
113-
.attr('class', '')
114-
.addClass('status wu-text-green-600')
115-
.find('> span').html(wu_setup[content].success).end()
116-
.find('.spinner').removeClass('is-active');
120+
successes++;
117121

118-
$item.removeAttr('data-content');
122+
} else {
119123

120-
successes++;
124+
$item.find('td.status')
125+
.attr('class', '')
126+
.addClass('status wu-text-red-400')
127+
.find('> span').html(data.data[ 0 ].message).end()
128+
.find('.spinner').removeClass('is-active').end()
129+
.find('a.help').slideDown();
121130

122-
} else {
131+
} // end if;
123132

124-
$item.find('td.status')
125-
.attr('class', '')
126-
.addClass('status wu-text-red-400')
127-
.find('> span').html(data.data[0].message).end()
128-
.find('.spinner').removeClass('is-active').end()
129-
.find('a.help').slideDown();
133+
index++;
130134

131-
} // end if;
135+
process_queue_item(queue.eq(index));
132136

133-
index++;
137+
},
138+
error(jqXHR) {
134139

135-
process_queue_item(queue.eq(index));
140+
let errorMessage = wu_setup_settings.generic_error_message || 'An error occurred.';
136141

137-
},
138-
error() {
142+
if (jqXHR.responseJSON && jqXHR.responseJSON.data && jqXHR.responseJSON.data[ 0 ]) {
143+
errorMessage = jqXHR.responseJSON.data[ 0 ].message || errorMessage;
144+
}
139145

140-
$item.find('td.status')
141-
.attr('class', '')
142-
.addClass('status wu-text-red-400')
143-
.find('span').html('').end()
144-
.find('.spinner').removeClass('is-active').end()
145-
.find('a.help').slideDown();
146+
$item.find('td.status')
147+
.attr('class', '')
148+
.addClass('status wu-text-red-400')
149+
.find('> span').html(errorMessage).end()
150+
.find('.spinner').removeClass('is-active').end()
151+
.find('a.help').slideDown();
146152

147-
index++;
153+
index++;
148154

149-
process_queue_item(queue.eq(index));
155+
process_queue_item(queue.eq(index));
150156

151-
},
152-
});
157+
},
158+
});
153159

154-
} // end process_queue_item;
160+
} // end process_queue_item;
155161

156-
});
162+
});
157163

158-
$('#poststuff [name=next]').removeAttr('disabled');
164+
$('#poststuff [name=next]').removeAttr('disabled');
159165

160-
});
166+
});
161167

162168
}(jQuery));
163169

164170
if (typeof wu_initialize_tooltip !== 'function') {
165171

166-
const wu_initialize_tooltip = function() {
172+
const wu_initialize_tooltip = function() {
167173

168-
jQuery('[role="tooltip"]').tipTip({
169-
attribute: 'aria-label',
170-
});
174+
jQuery('[role="tooltip"]').tipTip({
175+
attribute: 'aria-label',
176+
});
171177

172-
}; // end wu_initialize_tooltip;
178+
}; // end wu_initialize_tooltip;
173179

174-
// eslint-disable-next-line no-unused-vars
175-
const wu_block_ui = function(el) {
180+
// eslint-disable-next-line no-unused-vars
181+
const wu_block_ui = function(el) {
176182

177-
jQuery(el).wu_block({
178-
message: '<span>Please wait...</span>',
179-
overlayCSS: {
180-
backgroundColor: '#FFF',
181-
opacity: 0.6,
182-
},
183-
css: {
184-
padding: 0,
185-
margin: 0,
186-
width: '50%',
187-
fontSize: '14px !important',
188-
top: '40%',
189-
left: '35%',
190-
textAlign: 'center',
191-
color: '#000',
192-
border: 'none',
193-
backgroundColor: 'none',
194-
cursor: 'wait',
195-
},
196-
});
183+
jQuery(el).wu_block({
184+
message: '<span>Please wait...</span>',
185+
overlayCSS: {
186+
backgroundColor: '#FFF',
187+
opacity: 0.6,
188+
},
189+
css: {
190+
padding: 0,
191+
margin: 0,
192+
width: '50%',
193+
fontSize: '14px !important',
194+
top: '40%',
195+
left: '35%',
196+
textAlign: 'center',
197+
color: '#000',
198+
border: 'none',
199+
backgroundColor: 'none',
200+
cursor: 'wait',
201+
},
202+
});
197203

198-
return jQuery(el);
204+
return jQuery(el);
199205

200-
};
206+
};
201207

202-
(function($) {
208+
(function($) {
203209

204-
$(document).ready(function() {
210+
$(document).ready(function() {
205211

206-
wu_initialize_tooltip();
212+
wu_initialize_tooltip();
207213

208-
});
214+
});
209215

210-
}(jQuery));
216+
}(jQuery));
211217

212218
} // end if;

assets/js/setup-wizard.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/admin-pages/class-base-admin-page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function get_id() {
239239
}
240240

241241
/**
242-
* Returns the appropriate capability for a this page, depending on the context.
242+
* Returns the appropriate capability for this page, depending on the context.
243243
*
244244
* @since 2.0.0
245245
* @return string

0 commit comments

Comments
 (0)