generated from alleyinteractive/create-wordpress-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
81 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { arrowRight } from '@wordpress/icons'; | ||
import type { Command } from '@wordpress/commands'; | ||
|
||
/** | ||
* Collect all admin menu links as possible commands. | ||
*/ | ||
const adminMenu = (): Command[] => { | ||
const links = document.querySelectorAll('#adminmenu a'); | ||
const index: Command[] = []; | ||
|
||
Array.from(links).forEach((link) => { | ||
const url = link.getAttribute('href'); | ||
|
||
if (!url || url === '#') { | ||
return; | ||
} | ||
|
||
let label = link.textContent; | ||
|
||
if (url.endsWith('edit-comments.php')) { | ||
label = 'Comments'; | ||
} | ||
|
||
if (url && label) { | ||
index.push({ | ||
label: `Go to Settings: ${label}`, | ||
name: url, | ||
icon: arrowRight, | ||
callback: () => { | ||
window.location.href = url; | ||
}, | ||
}); | ||
} | ||
}); | ||
|
||
return index; | ||
}; | ||
|
||
export default adminMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import adminMenu from './adminMenu'; | ||
|
||
/** | ||
* Commands available to be added by the plugin. | ||
*/ | ||
const commands = () => [ | ||
...adminMenu(), | ||
]; | ||
|
||
export default commands; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters