Skip to content

Commit

Permalink
Merge pull request #20 from rosswintle/1-7-0-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rosswintle authored Mar 30, 2022
2 parents 5f34b94 + b7068bb commit 33f5a5d
Show file tree
Hide file tree
Showing 17 changed files with 1,872 additions and 239 deletions.
657 changes: 579 additions & 78 deletions dist/main.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/main.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "turbo-admin",
"version": "1.5.3",
"version": "1.7.0",
"main": "Gruntfile.js",
"author": "Ross Wintle",
"scripts": {
Expand Down
108 changes: 74 additions & 34 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,113 @@ Contributors: magicroundabout
Donate link: https://ko-fi.com/magicroundabout
Tags: menu, commands, shortcuts
Requires at least: 4.9
Tested up to: 5.8
Tested up to: 5.9
Requires PHP: 7.2
Stable tag: 1.5.3
Stable tag: 1.7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

The command palette that gives super fast access to your WordPress Dashboard.
== Description ==

If you love this plugin, you can get Turbo Admin on ALL your sites, without needing to install the plugin, with the browser extension version!
Ugh, this Dashboard menu is so cluttered?

[Check out the Browser Extension](https://turbo-admin.com/)
Where is everything?

== Description ==
Is it in Tools? Or Settings? Or some menu of it's own?

How am I supposed to work with this clutter?

## If the WordPress Dashboard is slowing you down, Turbo Admin is here to speed you up.

Work faster with WordPress using a quick-access command palette and a collection of Dashboard improvements. Simply install, activate and go!

Turbo Admin's main features are:

* A fast-action, keyboard driven command palette: Think Apple Spotlight, or Alfred, but in WordPress!
* (Experimental) Notice hiding: Tidy your dashboard by hiding admin notices in a separate, slide-out panel.
* (Experimental/Beta): List table keyboard shortcuts - use vim-like keys to navigate lsit tables.

If you love this plugin, you can get Turbo Admin on ALL your sites without needing to install the plugin, with the browser extension version!

PLUS the browser extension has features not present in the plugin because, well, they only make sense in the extension!

* Full screen block editor killer
* Block editor welcome guide remover
* Live/dev site labels

Remember, the browser extension it works everywhere that it can detect WordPress without needing a plugin. And it carries your preferences with you! It's WordPress, your way!

[Check out the Browser Extension and try it for free](https://turbo-admin.com/)

## Usage

Install, activate and then:
Install, activate and go!

## Using the Command Palette

The command palette is a keyboard-driven, pop-up menu.

The default keyboard shortcut to activate the command palette is:

* Windows: Ctrl-Alt-Shift-P (Linux also?)
* Mac: Cmd-Alt-Shift-P

You can customise the keyboard combination used in the settings in your user profile. Be careful not to choose a keyboard combination already used by your browser.
You can customise the keyboard combination used in the settings in your user profile. Be careful not to choose a keyboard combination already used by your browser!

Close the palette with Escape, clicking outside of it, or pressing Ctrl/Cmd-Alt-Shift-P (or your custom key combination) again.

Hover over the snail in the admin bar for a reminder of your shortcut at any time.

## Turbo Admin: The command palette that gives super fast access to your WordPress Dashboard.
You can:

Ugh, this Dashboard menu is so cluttered?
- type to filter the commands
- use up and down arrows to select an item
- press enter to select an item
- hit escape (not too hard) to close the palette

Where is everything?
You can also select items with your mouse/trackpad.

Is it in Tools? Or Settings? Or some menu of it's own?
If you hold Ctrl/Cmd when selecting an item it will open in a new tab/window (you may need to allow your browser to open popups).

How am I supposed to work with this clutter?
As well as commands, the plugin will also search content that is made available through the REST API (as long as the REST API can be discovered).

## If the WordPress Dashboard is slowing you down, Turbo Admin is here to speed you up.
## Using the (experimental) Notice Hiding feature

A customisable key-combination launches a command palette with all your menu items.
Notice hiding lets you move unwanted notices into a separate panel at the top-right of the dashboard.

Fuzzy search helps you find items even when you're not sure what they are called.
To turn on the Notice Hiding feature, visit your user profile, find the "Turbo Admin settings" section, and check the feature in the "Additional features" section. Be sure to click "Update Profile" to save the change.

If you've used Alfred App or Spotlight or the command palette in your text editor or IDE, you'll know the benefits of a tool like this and you'll quickly feel at home.
I have attempted to be somewhat "intelligent" in how I hide notices, automatically handling obvious cases, and giving you choice in other cases.

Install... activate... work faster!
This is why this feature is flagged as "Experimental" - I may not have the "intelligence" right just yet.

## How does it work?
[Read more about Turbo Admin's Notice Hiding](https://turbo-admin.com/hide-notices.html)

Install the plugin and activate it and then press Ctrl-Alt-Shift-P (or Cmd-Alt-Shift-P on a Mac) to open the palette.
The "Notices" tab in the top-right will show a red-circled number if there are notices to see.

The keyboard shortcut can be customised from settings in your user profile. Be careful not to choose a keyboard combination already used by your browser.
If Turbo Admin gives you the option of hiding a notice it will have a "Move to panel" button. Click this to move it to the panel. You can always move it back if you change your mind.

You can:
- type to filter the commands
- use up and down arrows to select an item
- press enter to select an item
- hit escape (not too hard) to close the palette
## Using the (experimental) List Table Keyboard Shortcuts feature

You can also select items with your mouse/trackpad.
This feature is documented on [the Turbo Admin website](https://turbo-admin.com/list-table-keys.html)

If you hold Ctrl/Cmd when selecting an item it will open in a new tab/window (you may need to allow your browser to open popups).
To turn on the List Table Keyboard Shortcuts feature, visit your user profile, find the "Turbo Admin settings" section, and check the feature in the "Additional features" section. Be sure to click "Update Profile" to save the change.

As well as commands, the plugin will also search content that is made available through the REST API (as long as the REST API can be discovered).
== Frequently Asked Questions ==

## Commands aren't showing on the front end of the site.
= Commands aren't showing on the front end of the site. =

You need to be logged in for Turbo Admin to work.

Commands are scraped from the menus on the WP Admin side and cached for use on the front end so if the palette is showing but with no commands you'll need to visit the Dashboard to get the menu cached.

## Content search isn't working.
= Content search isn't working. =

This could be for several reasons, but it's dependent on the REST API being discoverable and the content you want to search being available in the API.

It's known to not work in ClassicPress, when some security plugins hide the API's discovery, or when the API routes have been changed from the defaults.

## Can I hide the icon in the admin bar?
= Can I hide the icon in the admin bar? =

Yes, as of v1.5.3 there is an option to do this in each user's profile.

Expand All @@ -100,9 +129,9 @@ function ta_hide_icon($hide, $user_id) {
}
`

## Do I really have to install this on EVERY site?
= Do I really have to install this on EVERY site? =

It's funny you ask. There's also a (paid-for) [browser extension](https://turbo-admin.com) that will let you have Turbo Admin on every wp-admin without having to install anything!
It's funny you ask. There's also a [browser extension](https://turbo-admin.com) that will let you have Turbo Admin on every wp-admin without having to install anything!

== Installation ==

Expand All @@ -121,6 +150,17 @@ If you're reading this then you've probably already done step 1. So what are you

== Changelog ==

= 1.7.0 =
* [FEATURE] Re-designed notice hiding (still experimental)
* [FEATURE] List table keyboard shortcuts (experimental/alpha)
* [FEATURE] Oxygen builder support in the command palette
* [ENHANCEMENT] MUCH improved content search with better debouncing and caching
* [ENHANCEMENT] Improved palette startup time

= 1.6.0 =
* Note: The plugin version skipped this release
* [FEATURE] Notice hiding (experimental)

= 1.5.3 =
* Allow icon in admin bar to be hidden

Expand Down
65 changes: 65 additions & 0 deletions src/class-acf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
export default class Acf {

constructor() {

}

/**
* Returns true if the code detects that ACF is installed
* (only works back-end).
*
* @returns {boolean}
*/
isAcfInstalled() {
return null !== document.getElementById('toplevel_page_edit-post_type-acf-field-group')
}

/**
* Returns the URL of the ACF screen in the backend.
* (TODO: Store this somewhere?)
*
* @returns {string}
*/
acfScreenUrl() {
const elem = /** @type {HTMLAnchorElement} */(document.getElementById('toplevel_page_edit-post_type-acf-field-group')?.querySelector('a.menu-top'));
return elem?.href;
}

/**
* Gets the field groups from the ACF screen
* Returns a promise that resolves to an array of objects like:
* {
* label: <label>
* link: <url>
* }
*
* @returns {Promise}
*/
async getFieldGroups() {
const response = await fetch(
this.acfScreenUrl(),
{
"headers": {
'X-Requested-With': 'XMLHttpRequest',
'Cache-Control': 'no-cache'
},
"method": "GET",
"credentials": 'include',
"cache": "no-cache",
"mode": "cors"
}
)
const text = await response.text()
const dom = document.createRange().createContextualFragment(text)
const items = /** @type {NodeListOf<HTMLAnchorElement>} */(
dom.querySelectorAll('tr.type-acf-field-group a.row-title')
)
return Array.from(items).map(
item => {
return { label: item.innerText, link: item.href }
},
items
)
}

}
52 changes: 51 additions & 1 deletion src/class-content-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export default class ContentApi {
// console.log('Discovered API base: ', this.apiBase);
this.active = false;
this.store = new Storage();

// This is used to "cache" duplicate requests.
// It's an object because it will have search strings as keys
this.cache = {};
}

async discoverApiRoot() {
Expand Down Expand Up @@ -78,12 +82,58 @@ export default class ContentApi {
const params = new URLSearchParams();

Object.keys(data).forEach(paramKey => {
params.append(paramKey, data[paramKey]);
// Handle arrays
if (Array.isArray(data[paramKey])) {
const arrayParamKey = paramKey + '[]';
data[paramKey].forEach( item => params.append(arrayParamKey, item));
} else {
params.append(paramKey, data[paramKey]);
}
});

return params.toString();
}

statuses() {
if (this.apiNonce) {
return ["publish", "future", "draft", "pending", "private"];
} else {
return ["publish"];
}
}

types() {
return globalThis.turboAdmin.turboAdminPalette.postTypes;
}

async getPosts(searchString) {
// Check the cache
if (undefined !== this.cache[searchString]) {
return this.cache[searchString];
}

// Fetch results
const response = await this.get(
// "posts",
"search",
{
search: searchString,
per_page: 100,
// status: this.statuses(),
type: 'post',
subtype: 'any'
}
);

// Decode JSON
const result = await response.json();

// Store in the cache
this.cache[searchString] = result;

return result;
}

async get(path, data = {}) {
const init = {
method: 'GET',
Expand Down
Loading

0 comments on commit 33f5a5d

Please sign in to comment.