-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreadme.txt
395 lines (250 loc) · 8.95 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
=== Super Admin All Sites Menu ===
Stable tag: 1.8.4
Requires at least: 5.6
Tested up to: 6.7
Requires PHP: 8.0
License: GPL v2 or later
Tags: superadmin, multisite, management
Contributors: PerS
Donate link: https://www.paypal.com/paypalme/PerSoderlind
For the super admin, replace WP Admin Bar My Sites menu with an All Sites menu.
== Description ==
* Doesn't use `switch_to_blog()`, i.e. Super Admin All Sites Menu is faster and uses less resources than the WP Admin Bar My Sites menu.
* Subsite menu data are stored locally in IndexedDB (did I say it's fast?). The local storage is updated when;
* the plugin is activated.
* a site is added or deleted.
* you change a blog name.
* IndexedDB is out of sync with site changes.
* [Restricted Site Access](https://github.com/10up/restricted-site-access) is activated or deactivated.
* When subsite menu data is updated, AJAX is used and it's done in increments (100 sites per increment).
* List all subsites. WP Admin Bar My Sites only list sites you're a local admin on.
* Mark sites that has [restricted site access](https://github.com/10up/restricted-site-access) with a red icon.
* Sites menu is sorted alphabetically.
* Search filter.
* Add more menu choices:
* Under "Network Admin"
* Add New Site
* Per subsite.
* 'New Page'
* 'Users'
* 'Plugins'
* 'Settings'
= Prerequisite =
* WordPress Multisite
* A modern browser, IE 11 isn't supported.
= Demo =
A demo is available in [WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/soderlind/super-admin-all-sites-menu/refs/heads/main/blueprint.json). It's a bit slow loading, 50 subsites are added.
- If you disable Super Admin All Sites Menu in the Main Site plugins menu, you'll see the WP Admin Bar My Sites menu doesn't allow you to scroll and see all sites. This is a 14-year-old (!) [bug on WordPress](https://core.trac.wordpress.org/ticket/15317).
- If you activate the Restricted Site Access plugin (included), you'll see a red icon next to the site name. ATM, this only works on the main site due to [issues with WordPress Playground](https://github.com/WordPress/wordpress-playground/issues/2054).
= Filters =
You can use the following filters to override the defaults:
* `all_sites_menu_order_by`
* Sort menu by. Default value is `name`, accepts `id`, `url` or `name`
`
add_filter( 'all_sites_menu_order_by', function( string $order_by ) : string {
return 'url';
} );
`
* `all_sites_menu_load_increments`
* AJAX load increments. Default value is 100.
`
add_filter( 'all_sites_menu_load_increments', function( int $increments ) : int {
return 300;
} );
`
* `all_sites_menu_plugin_trigger`
* Trigger an update of local storage (IndexedDB) when a plugin is (de)activated. Default is `[ 'restricted-site-access/restricted_site_access.php' ]`.
> Note: Must be an array and each element in the array must point to the main plugin file. Syntax `'plugin-dir/plugin-file.php'`
`
add_filter( 'all_sites_menu_plugin_trigger', function( array $plugins ) : array {
return [
'restricted-site-access/restricted_site_access.php',
'myplugin/myplugin.php',
];
} );
`
* `all_sites_menu_search_threshold`
* Don't display search field if there's less than N subsites. Default value is 20.
`
add_filter( 'all_sites_menu_search_threshold', function( int $increments ) : int {
return 40;
} );
`
* `all_sites_menu_search_threshold`
* Don't display search field if there's less than N subsites. Default value is 20.
`
add_filter( 'all_sites_menu_search_threshold', function( int $increments ) : int {
return 40;
} );
`
* `all_sites_menu_force_refresh_expiration`
* How often a forced refresh should be taken. Default value is `3600`. Set the value to `0` to disable forced refresh.
`
add_filter( 'all_sites_menu_force_refresh_expiration', function( int $seconds ) : int {
return 3600;
} );
`
= Development =
* Active development of this plugin is handled [on GitHub](https://github.com/soderlind/super-admin-all-sites-menu).
== Screenshots ==
1. Demo
2. Menu data are stored locally in IndexedDB.
== Changelog ==
= 1.8.4 =
* Update dependencies
= 1.8.3 =
* Housekeeping
= 1.8.2 =
* Abort early if the user does not have the required permissions
* Security: Added endpoint verification for REST API requests
* Bug fix: Added rest endpoint permission check
* Code improvement: Added strict types declaration
* Code improvement: Added return type declarations
= 1.8.1 =
* Remove duplicate code
= 1.8.0 =
REQUIRE PHP 8.0 OR HIGHER
* Code modernization: Refactored to use PHP 8.0+ features
* Enhancement: Improved type safety and error handling
* Performance: Better code organization with Config class
* Enhancement: Increased default search threshold to 20 sites
= 1.7.3 =
* Fixed search functionality:
* Improved search performance with better indexing
* Added mutation observer to handle dynamically loaded sites
* Fixed event handling for search input
* Added improved error handling for search elements
* Better handling of empty search inputs
= 1.7.2 =
- Bump version to trigger a deploy to WordPress.org
= 1.7.1 =
- Bump version to trigger a deploy to WordPress.org
= 1.7.0 =
- Major code refactoring and improvements:
- Added comprehensive JSDoc documentation
- Improved error handling throughout the codebase
- Enhanced IndexedDB implementation with private class fields
- Added debouncing to search functionality
- Improved intersection observer implementations
- Better type checking and null safety
- Modernized class structure and module organization
= 1.6.9 =
- Update dependencies
= 1.6.8 =
- Update dependencies
= 1.6.7 =
- Update dependencies
= 1.6.6 =
- Tested with WordPress 6.4
= 1.6.5 =
- Tested with WordPress 6.3
= 1.6.4 =
- Fix bug in handling the REST API.
= 1.6.2 =
- Tested with WordPress 6.0
= 1.6.1 =
* Await for the promise `populateDB()` to resolve before continuing.
= 1.6.0 =
* Use `@wordpress/api-fetch` to fetch subsite data.
= 1.5.0 =
* Use REST instead of AJAX.
= 1.4.28 =
* Housekeeping
= 1.4.27 =
* Add missing textdomain to translations.
* Update uninstall.php
= 1.4.26 =
* Bundle Dexie using wp-scripts
= 1.4.25 =
* Housekeeping
= 1.4.24 =
* Use @wordpress/i18n to translate JavaScript.
= 1.4.23 =
* Fix typo in textdomain.
= 1.4.22 =
* Housekeeping
= 1.4.21 =
* Update translation file (.pot)
= 1.4.20 =
* Don't set dependencies for style.
= 1.4.19 =
* Import @wordpress/i18n
= 1.4.18 =
* Replace build script from webpack to wp-scripts (@wordpress/scripts)
= 1.4.17 =
* Use correct AJAX URL
= 1.4.16 =
* Upgrade Dexie.js to v 3.2.0
= 1.4.15 =
* Only load the plugin code if the admin bar is available.
= 1.4.14 =
* Force refresh using a site transient.
= 1.4.13 =
* Don't list sites that are tagged as archived, deleted, mature or spam.
= 1.4.12 =
* Update plugin banner
= 1.4.11 =
* Add plugin banner
= 1.4.10 =
- Housekeeping
= 1.4.9 =
* Deploy to https://wordpress.org/plugins/super-admin-all-sites-menu/
= 1.4.8 =
* Remove external dependencies.
= 1.4.7 =
* Remove `type=module` from script tag. Not needed anymore since the script and modules are packed.
= 1.4.6 =
* Pack JavaScript using webpack.
= 1.4.5 =
* Only run if multisite.
* Improved Dexie versioning.
= 1.4.4 =
* Pass only one parameter to `plugin_update_local_storage()`
* Close db connection when getting version number.
= 1.4.3 =
* IndexedDB maintenance, i.e. remove old databases.
= 1.4.2 =
* Dexie schema change, bump Dexie version number.
= 1.4.1 =
* Make sure the local storage (IndexedDB) is in sync with server changes.
= 1.4.0 =
* Refactored JavaScript again, I'm using this plugin to experiment with and to learn JavaScript better.
= 1.3.8 =
* Refactor and rename db module.
= 1.3.7 =
* Don't display search field if there's less than 20 subsites. The threshold is adjustable using the `all_sites_menu_search_threshold` filter
= 1.3.6 =
* Fix load increments bug.
= 1.3.5 =
* Housekeeping.
= 1.3.4 =
* Add filters to defaults.
= 1.3.3 =
* Update IndexedDB when you change a blog name.
= 1.3.2 =
* Only change `text/javscript`to `module` when tag has `src` attribute
= 1.3.0 =
* Refactor
* Split JavaScript into modules
* If empty, populate IndexedDB with sites menu data.
= 1.2.4 =
* Adjust the sites menu wrapper height
= 1.2.3 =
* Remove `window.hoverintent`, it's slow when you have a lot of sites, use `addEventListener` in capturing mode instead.
= 1.2.2 =
* Housekeeping.
= 1.2.1 =
* Update IndexedDB when Restricted Site Access is (de)activated.
= 1.2.0 =
* Store subsite menu data in IndexedDB (local storage).
* IndexedDB is updated when a site is added / deleted.
* Add search.
= 1.1.2 =
* Fix translations.
= 1.1.1 =
* Housekeeping.
= 1.1.0 =
* Lazy load the subsite menu, using IntersectionObserver and AJAX, loading only 80 subsites at a time.
* Make subsites menu scrollable.
= 1.0.x =
* Initial release.