soderlind / super-admin-all-sites-menu
For the super admin, replace WP Admin Bar My Sites menu with an All Sites menu.
Installs: 227
Dependents: 0
Suggesters: 0
Security: 0
Stars: 26
Watchers: 3
Forks: 2
Open Issues: 2
Type:wordpress-plugin
- dev-main
- 1.6.7
- 1.6.6
- 1.6.4
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.0
- 1.4.28
- 1.4.27
- 1.4.26
- 1.4.25
- 1.4.24
- 1.4.23
- 1.4.22
- 1.4.21
- 1.4.20
- 1.4.19
- 1.4.18
- 1.4.17
- 1.4.16
- 1.4.15
- 1.4.14
- 1.4.13
- 1.4.12
- 1.4.11
- 1.4.10
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/npm_and_yarn/word-wrap-1.2.4
- dev-dependabot/npm_and_yarn/tough-cookie-4.1.3
This package is auto-updated.
Last update: 2024-04-15 21:03:58 UTC
README
Also available at https://wordpress.org/plugins/super-admin-all-sites-menu/
Use | Prerequisite | Install | Filters | Demo | Changelog
For the super admin, replace WP Admin Bar My Sites menu with an All Sites menu.
- 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 is activated or deactivated.
- When subsite menu data is updated, REST 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 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'
- Under "Network Admin"
Inspired by WP REST API vs admin-ajax.php vs Must-Use Plugin: Handling AJAX Requests in WordPress, I wrote a must-use plugin that makes the plugin go from fast to faster (ca 60% faster). Save the file in
mu-plugins
.
Use
IndexedDB
Menu data are stored locally in IndexedDB.
Prerequisite
- WordPress Multisite
- A modern browser, IE 11 isn't supported.
Install
Also available at https://wordpress.org/plugins/super-admin-all-sites-menu/
Filters
You can use the following filters to override the defaults:
all_sites_menu_order_by
- Sort menu by. Default value is
name
, acceptsid
,url
orname
add_filter( 'all_sites_menu_order_by', function( string $order_by ) : string { return 'url'; } );
- Sort menu by. Default value is
all_sites_menu_load_increments
- REST 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', ]; } );
- Trigger an update of local storage (IndexedDB) when a plugin is (de)activated. Default is
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 to0
to disable forced refresh.add_filter( 'all_sites_menu_force_refresh_expiration', function( int $seconds ) : int { return 3600; } );
- How often a forced refresh should be taken. Default value is
Demo
Localy, in VS Code
Test the plugin on a WordPress Multisite with 100 sites, locally, using VS Code dev containers.
- You must have docker installed.
- In VS Code, install the Remote - Containers extension.
- Clone Super Admin All Sites Menu:
git clone https://github.com/soderlind/super-admin-all-sites-menu
- In
super-admin-all-sites-menu
, open VS Code:code .
- When VS Code opens, click on Reopen container
- Wait until the container is ready, then open http://localhost:8080/wp-admin/
- Username:
admin
- Password:
password
- Username:
In GitHub Codespaces
- Click the Code drop-down menu and select the
Create codespace on main
. - Wait until VS Code runs in the browser
- In VS Code, Select
PORTS
and click on theLocal Address
URL. - Append
/wp-admin
to the Local Address URL- Username:
admin
- Password:
password
- Username:
Flow
sequenceDiagram Actor User participant Menu participant IndexedDB participant WordPress User->>Menu: Open the menu Menu->>IndexedDB: Check if IndexedDB in sync IndexedDB->>Menu: Update sites menu Note over Menu,IndexedDB: If in sync. IndexedDB->>WordPress: Request sites Note over IndexedDB,WordPress: If not in sync. WordPress->>IndexedDB: Get sites IndexedDB->>IndexedDB: Update IndexedDB IndexedDB->>Menu: Update sites menu Menu->>User: Read Menu
Changelog
See CHANGELOG.md
Credits
- Dexie.js, which has an Apache License Version 2.0
- Submmenu offset adjustment: https://qiita.com/zephyr7501/items/dd0967fddabd888b28c4
- CSS for search field from https://github.com/trepmal/my-sites-search
Copyright and License
Super Admin All Sites Menu is copyright 2021 Per Soderlind
Super Admin All Sites Menu is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
Super Admin All Sites Menu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Extension. If not, see http://www.gnu.org/licenses/.