Creating Commands for the Commands Palette

๐ **Source:** [Creating Commands for the Commands Palette](https://www.youtube.com/watch?v=ETqUp0UXH0k)
> [!note]+ Document Notes
> tags: [wordpress, command-palette, gutenberg, developer-tools, react-hooks]
> author: Mario Santos
> source: YouTube Live Stream
> reference: [https://www.youtube.com/watch?v=ETqUp0UXH0k]
> date created: 2024-12-19 10:30
>
> # ๐ท๏ธ Title: Creating commands for the Commands Palette
>
<!-- deep-read:sections start -->
## ๐งฐ Action Inbox
- [H1] Implement handbook quick access commands โ use WP.data.dispatch for simple navigation #commands
- [H2] Create modal-based commands with React hooks โ mount React components manually #react-integration
- [H3] Add contextual commands for block editor โ use register_plugin for editor-specific features #block-editor
## ๐งญ Table of Contents
- [๐ Summary](#-summary)
- [๐ Main Content](#-main-content)
- [๐๏ธ Notes](#๏ธ-notes)
- [๐ References](#-references)
- [๐ฃ๏ธ Paraphrase](#๏ธ-paraphrase)
- [๐ฐ Newsletter](#-newsletter)
- [โ
Action Items](#-action-items)
- [๐งช Hypotheses](#-hypotheses)
- [๐ Methodology](#-methodology)
- [โ Questions](#-questions)
- [๐ฎ Future Research](#-future-research)
- [๐ก Implications](#-implications)
- [๐ง Learning Styles Assessment](#-learning-styles-assessment)
- [๐ Accessibility Assessment](#-accessibility-assessment)
- [๐ DEIB Assessment](#-deib-assessment)
- [โ
Logical Validity](#-logical-validity)
- [๐ก๏ธ DARVO Analysis](#-darvo-analysis)
- [๐ฏ Conclusion](#-conclusion)
### ๐ References
- [WordPress Developer Blog](https://developer.wordpress.org/news/)
- [Mario's GitHub](https://github.com/WordPress)
- [Stream Resources Repository](https://github.com/WordPress/streams)
## ๐ Summary
- WordPress 6.9 expanded command palette availability from block editor only to entire admin area
- Three main approaches for creating custom commands: WP.data.dispatch, React hooks with manual mounting, and register_plugin for editor contexts
- Commands can be contextual (site-editor, entity-edit, block-selection-edit) for better UX prioritization
- Challenges exist with React hooks requiring React environment while admin pages may lack this
## ๐ Main Content
WordPress 6.9 introduced a significant expansion of the command palette, making it available throughout the entire admin interface rather than just within the block and site editors. This creates new opportunities but also technical challenges for developers creating custom commands.
The core challenge stems from WordPress's data layer architecture. Many helper functions for command creation are React hooks that require a React environment to function. However, traditional admin pages outside the editor don't provide this React context, necessitating creative solutions for universal command compatibility.
Three distinct approaches have emerged for command creation, each suited to different use cases and technical requirements. The choice depends on where commands need to function and what level of interactivity is required.
## ๐๏ธ Notes
#### โฑ๏ธ [00:00](https://youtu.be/ETqUp0UXH0k?t=0) โ [H1] Session introduction and context
- Key idea: Live coding session exploring command palette development
- Evidence: "WordPress 6.9 the command palette is available everywhere"
#### โฑ๏ธ [05:23](https://youtu.be/ETqUp0UXH0k?t=323) โ [H2] Command palette expansion in WordPress 6.9
- Key idea: Command palette now works beyond just editors
- Evidence: "Before WordPress 6.9 the common palette was only available in the block editor"
#### โฑ๏ธ [08:45](https://youtu.be/ETqUp0UXH0k?t=525) โ [H3] React hooks challenge outside editor context
- Key idea: Hooks require React environment not always available
- Evidence: "These hooks can only be executed inside React components"
#### โฑ๏ธ [12:30](https://youtu.be/ETqUp0UXH0k?t=750) โ [H1] First approach: Direct dispatch method
- Key idea: Use WP.data.dispatch for simple command registration
- Evidence: "We can use the dispatch method of WordPress data"
#### โฑ๏ธ [18:15](https://youtu.be/ETqUp0UXH0k?t=1095) โ [H2] Demonstrating handbook navigation commands
- Key idea: Register commands to access WordPress handbooks directly
- Evidence: "Commands to access directly the handbooks directly from the command palette"
#### โฑ๏ธ [25:40](https://youtu.be/ETqUp0UXH0k?t=1540) โ [H2] Redux store inspection for commands
- Key idea: Command store visible in Redux DevTools
- Evidence: "One of the stores we have is called commands"
#### โฑ๏ธ [32:10](https://youtu.be/ETqUp0UXH0k?t=1930) โ [H1] Second approach: useCommand hook with manual React mounting
- Key idea: Create DOM element and render React component for hook usage
- Evidence: "We need to find a way of mounting manually a react container"
#### โฑ๏ธ [38:50](https://youtu.be/ETqUp0UXH0k?t=2330) โ [H2] Latest posts modal command demonstration
- Key idea: Modal interface for browsing and navigating to recent posts
- Evidence: "We can go to the specific post and we can show latest posts"
#### โฑ๏ธ [45:20](https://youtu.be/ETqUp0UXH0k?t=2720) โ [H3] Using useSelect hook for data fetching
- Key idea: Leverage WordPress data layer for dynamic content
- Evidence: "I'm using the useSelect which returns the post and is loading"
#### โฑ๏ธ [52:15](https://youtu.be/ETqUp0UXH0k?t=3135) โ [H1] Third approach: register_plugin for editor contexts
- Key idea: Use existing React environment in block editor
- Evidence: "If we are in the block editor we can leverage register plugin"
#### โฑ๏ธ [58:30](https://youtu.be/ETqUp0UXH0k?t=3510) โ [H2] Contextual commands and prioritization
- Key idea: Commands can be contextualized for better UX
- Evidence: "Commands can be contextual. This means that in a given context some specific commands are given more priority"
#### โฑ๏ธ [64:45](https://youtu.be/ETqUp0UXH0k?t=3885) โ [H2] Copy post content command implementation
- Key idea: Editor-specific command using clipboard API
- Evidence: "navigator clipboard write text content"
#### โฑ๏ธ [71:20](https://youtu.be/ETqUp0UXH0k?t=4280) โ [H3] Block usage analysis command
- Key idea: Dynamic command loader for analyzing block usage
- Evidence: "useCommandLoader used for dynamic commands"
#### โฑ๏ธ [78:10](https://youtu.be/ETqUp0UXH0k?t=4690) โ [H2] Context restrictions and user permissions
- Key idea: Commands can be restricted based on editing context
- Evidence: "canUser edit post returns true only when editing a post"
## ๐ References
- [WordPress Command Palette Documentation](https://developer.wordpress.org/block-editor/reference-guides/data/data-commands/)
- [Gutenberg Repository](https://github.com/WordPress/gutenberg)
- [WordPress Data Package](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-data/)
## ๐ฃ๏ธ Paraphrase
- WordPress 6.9 brought command palette functionality to all admin pages, not just editors, creating new development opportunities
- Three main patterns exist for command creation: simple dispatch calls, React hook mounting, and editor plugin registration
- Commands can be made contextual to appear first in relevant editing environments like site editor or block selection
## ๐ฐ Newsletter
**WordPress Command Palette Gets Major Expansion**
WordPress 6.9 has opened exciting new possibilities for developer productivity with the command palette now available throughout the entire admin interface. This expansion means you can create custom commands that work everywhere from the dashboard to post listings.
**Key Development Approaches:**
- **Simple Navigation**: Use `WP.data.dispatch()` for basic commands like handbook links
- **Interactive Modals**: Mount React components manually for complex interfaces
- **Editor Integration**: Leverage `register_plugin()` for block editor specific features
The contextual command system is particularly clever - your editor commands automatically get priority when relevant, creating a more intuitive user experience.
**Next Steps**: Start with simple navigation commands using the dispatch method, then explore React integration as your needs grow complex.
Resources: [Developer Docs](https://developer.wordpress.org/), [Command API Reference](https://developer.wordpress.org/block-editor/reference-guides/data/data-commands/), [Live Coding Archive](https://youtube.com/@mariosantos)
## โ
Action Items
#### WordPress
- Core: Investigate additional command contexts beyond site-editor, entity-edit, block-selection-edit
- Core: Consider command grouping/categorization for better organization
- Core: Explore command descriptions and tooltips for enhanced UX
- Documentation: Create comprehensive command palette development guide
- Documentation: Document screen checking in PHP for conditional JS loading
#### Community
- Contributors: Share command palette plugins and use cases
- Contributors: Test command palette accessibility across different admin contexts
- Maintainers: Evaluate command palette integration opportunities in existing plugins
## ๐งช Hypotheses
- Command palette usage will increase developer productivity in WordPress admin workflows
- Contextual commands will reduce cognitive load by showing relevant options first
- Manual React mounting approach will become standard pattern for complex commands
- Screen-based PHP loading checks will improve performance over universal JS loading
### ๐ Methodology
- Create test commands using all three approaches and measure implementation complexity
- User testing to compare navigation efficiency with and without custom commands
- Performance analysis of React mounting vs dispatch methods
- Accessibility testing across different admin page contexts
### โ Questions
- How can we improve the architecture for commands requiring React hooks outside editor contexts?
- What additional command contexts would be most valuable for developers?
- How should commands be grouped or categorized as the ecosystem grows?
### ๐ฎ Future Research
- Command palette performance optimization techniques
- Integration patterns with existing WordPress admin workflows
- Accessibility best practices for modal-based commands
### ๐ก Implications
- Practice: Command palette becomes essential skill for WordPress developers
- Policy: May influence WordPress admin interface design patterns
- Security: Custom commands need careful permission checking and validation
- Education: Training needed on React integration patterns outside traditional editor context
### ๐ง Learning Styles Assessment
Reading level estimate: Grade 12
#### ๐ Visual learners
- Present: Code examples, command palette screenshots, Redux DevTools inspection
- Improve: Architecture diagrams showing different command registration flows
#### ๐ Aural learners
- Present: Live coding explanation with verbal narration
- Improve: Audio summary of key concepts and decision points
#### ๐ฃ๏ธ Verbal learners
- Present: Clear explanations of technical terms, API analogies
- Improve: More real-world use case stories and examples
#### ๐งฉ Kinesthetic learners
- Present: Live coding session, copy-paste examples, hands-on demonstrations
- Improve: Step-by-step implementation checklists
#### ๐ง Logical learners
- Present: Clear approach categorization, decision trees for method selection
- Improve: Flowcharts for when to use each approach
#### ๐งโ๐คโ๐ง Social learners
- Present: Live chat interaction, community resource sharing
- Improve: Group coding exercises, command sharing gallery
#### ๐งโโ๏ธ Solitary learners
- Present: Self-contained code examples, individual exploration
- Improve: Self-assessment quizzes on approach selection
#### ๐ฟ Naturalistic learners
- Present: Organic development flow, iterative problem-solving
- Improve: Ecosystem thinking about command relationships
### ๐ Accessibility Assessment
#### Screen reader semantics
- Present: Code structure with proper headings
- Improve: Alt text for code screenshots, ARIA labels for live demo
#### Keyboard navigation
- Present: Command palette designed for keyboard-first interaction
- Improve: Ensure all demo commands are keyboard accessible
#### Contrast and readability
- Present: High contrast code examples
- Improve: Check video streaming contrast levels
#### Text resizing and reflow
- Present: Code examples scale appropriately
- Improve: Ensure video player controls remain accessible when zoomed
#### Media and captions
- Present: Live verbal explanation
- Improve: Auto-generated captions, transcript availability
#### Forms and interactions
- Present: Command palette interactions well-labeled
- Improve: Error state handling in custom commands
### ๐ DEIB Assessment
#### Cultural breadth
- Present: English-language focused but open to global participation
- Improve: Multi-language command examples, internationalization discussion
#### Inclusive language
- Present: Technical terms explained, jargon defined
- Improve: Plain language summaries, avoid assumptions about prior knowledge
#### Neurodiversity support
- Present: Clear structure, consistent pacing
- Improve: Content warnings for rapid code changes, pause points
#### Representation
- Present: Single presenter but encouraging community participation
- Improve: Guest perspectives, diverse use case examples
#### Psychological safety
- Present: Encouraging questions, admitting uncertainty
- Improve: Explicit welcome for all skill levels
### โ
Logical Validity
#### Strong reasoning
- Deductive strength: Clear categorization of three command approaches based on technical constraints
- Inductive strength: Examples build from simple to complex implementations
- Causal reasoning: Links technical limitations to architectural solutions
- Analogical strength: Good comparison between editor vs admin contexts
#### Fallacies
- None identified: Technical explanations are well-grounded in code examples
#### Tone of voice
- Overall tone: Collaborative and exploratory, encouraging experimentation and learning
### ๐ก๏ธ DARVO Analysis
- Deny: Not applicable - technical content
- Attack: Not applicable - technical content
- Reverse victim/offender: Not applicable - technical content
- Emotional cues and rhetoric: Positive, encouraging tone promoting learning and exploration
## ๐ฏ Conclusion
WordPress 6.9's expanded command palette creates significant opportunities for improving developer and user workflows throughout the admin interface. The three main approaches - direct dispatch, React hook mounting, and register_plugin integration - each serve specific use cases and technical requirements.
For developers, start with simple navigation commands using the dispatch method, then progress to React integration as complexity needs grow. The contextual command system provides elegant UX prioritization that should be leveraged thoughtfully.
The broader implications suggest command palette development will become an essential skill for WordPress developers, potentially influencing how we design admin interfaces and user workflows across the entire ecosystem.
## ๐งฑ Refactor Appendix
### ๐ Literature Split Pad
### [H1] Command palette expansion enables universal admin commands
> [!quote] [Creating commands for the Commands Palette](https://www.youtube.com/watch?v=ETqUp0UXH0k) by [[Mario Santos]] via [[YouTube]]. Published 2024-12-19. Accessed 2024-12-19.
> "WordPress 6.9 the command palette is available everywhere"
Significant expansion from editor-only to admin-wide availability.
[view highlight](https://youtu.be/ETqUp0UXH0k?t=323) #wordpress #command-palette ID:rw_cmd_palette_expansion
### [H2] React hooks require environment outside traditional admin
> [!quote] Creating commands for the Commands Palette
> "These hooks can only be executed inside React components"
Core technical challenge for universal command compatibility.
[view highlight](https://youtu.be/ETqUp0UXH0k?t=525) #react #wordpress-architecture ID:rw_hooks_challenge
---
### ๐ Atomic Split Pad (Zettel Candidates)
#### [Z1] Three patterns exist for WordPress command registration
- Simple dispatch, React mounting, register_plugin approaches each serve different contexts
- Pointer to 12:30 timestamp and implementation examples
- Links: [[WordPress-Command-Palette]] [[React-Integration-Patterns]]
#### [Z2] Contextual commands improve user experience through prioritization
- Commands appear first in relevant contexts like site-editor or entity-edit
- Pointer to 58:30 timestamp and context demonstration
- Links: [[User-Experience-Design]] [[WordPress-Admin-Interface]]
---
### โ๏ธ Fleeting Queue
- [F1] Explore command grouping solutions for growing ecosystem โ GitHub issues discussion #fleeting #commands
- [F2] Test
---
## Full Transcript
[04:01] and we are live.<br>[04:05] Let me send a message<br>[04:08] and then we can start with the session.<br>[04:15] In the meantime, please say hi if you<br>[04:17] are there.<br>[04:44] Okay,<br>[04:49] we are connected and the<br>[05:02] I'm sharing this session<br>[05:05] in a slack<br>[05:07] child.<br>[05:25] Okay.<br>[05:29] Yes. So people<br>[05:31] are aware of this.<br>[05:41] And now I'm ready.<br>[05:44] Okay, welcome<br>[05:47] everybody to another session,<br>[05:52] another stream,<br>[05:55] another stream where um<br>[05:59] I usually just work in public about<br>[06:02] stuff and I share what I have learned<br>[06:04] during the the week and yeah, it's like<br>[06:08] an open space so anyone can connect and<br>[06:12] ask questions.<br>[06:14] and yeah maybe just chip in<br>[06:19] how<br>[06:20] other developer is working about<br>[06:22] something.<br>[06:24] So today I want to explore a bit further<br>[06:30] the command palid and the creation of<br>[06:33] commands.<br>[06:34] I've been<br>[06:37] exploring this a little bit in this past<br>[06:41] uh few days.<br>[06:44] And I'm actually in the middle of<br>[06:46] exploring some stuff. So I want to share<br>[06:48] that with you and maybe work on these<br>[06:49] things together and see what we can<br>[06:54] what we can do or if we can solve<br>[06:56] something or if we can create some uh<br>[06:59] new commands. I also<br>[07:03] published this article a few weeks ago<br>[07:12] because I started this exploration. I<br>[07:14] actually did another stream<br>[07:19] at the yeah a few weeks ago in Spanish<br>[07:23] and I struggle with a few things<br>[07:26] so I decided to write about it. The<br>[07:29] thing is that um now in WordPress 6.9<br>[07:36] the command pallet is um it's available<br>[07:40] everywhere. Before<br>[07:43] WordPress 6.9<br>[07:46] the common pallet was only available in<br>[07:49] the block editor in the post editor or<br>[07:53] in the site editor but now it's<br>[07:56] available um everywhere. So that comes<br>[08:01] this brings new challenges. Um<br>[08:05] the main challenge I faced is that when<br>[08:08] you create commands there are some<br>[08:11] helpers to create these commands but a<br>[08:13] lot of these helpers are hook are hooks<br>[08:17] and these hooks can only be executed<br>[08:20] inside React components.<br>[08:22] And the thing is that outside of the<br>[08:25] post editor<br>[08:27] there are no usually uh there's no react<br>[08:30] environment.<br>[08:32] So we if we want to use those hooks and<br>[08:36] those hooks are useful if we want to<br>[08:39] interact with a store or something like<br>[08:41] that. We need to find a way to<br>[08:45] make or<br>[08:47] command to work in<br>[08:52] all the the contexts in all the<br>[08:56] environments. It should work either in a<br>[08:59] page that has a react<br>[09:04] um<br>[09:06] environment and in pages that doesn't<br>[09:08] have that react environment.<br>[09:10] Um so yeah, I did an exploration. I came<br>[09:14] up with a few solution. I would like to<br>[09:15] review them to see if we can improve the<br>[09:18] the approach on each of them.<br>[09:22] and<br>[09:24] okay the chat sorry if I don't answer in<br>[09:28] the chat because the chat is not<br>[09:30] connecting here let me see if I can<br>[09:34] solve this somehow<br>[09:36] and now I can see the chat<br>[09:40] hello<br>[09:46] so yeah if you are there say hi say<br>[09:52] from where you are connecting.<br>[09:57] And yeah, if you have any any questions<br>[09:59] about this um<br>[10:02] this whole thing of creating commands<br>[10:05] for the for the command pallet.<br>[10:11] Okay. So let's start by<br>[10:15] I'm going to show what I have so far of<br>[10:19] the expiration that I'm doing and I'm<br>[10:22] also in the middle of checking a pull<br>[10:24] request that has to do with this<br>[10:26] creation of commands. So maybe we can<br>[10:28] explore that together and then maybe we<br>[10:31] can uh we can go through these different<br>[10:35] examples and<br>[10:38] and just talk about them.<br>[10:41] I think that what I'm going to do is I'm<br>[10:43] going to share. Let me see if I where do<br>[10:48] I have this? I think it's here.<br>[10:54] Yeah, this is the project that I have.<br>[10:58] And this is the article.<br>[11:00] So, yeah, let's start. I think we can<br>[11:03] start here by<br>[11:06] or maybe we can check the the<br>[11:07] documentation a little bit.<br>[11:15] Uh, I have to. Okay, let me see.<br>[11:20] I'm not logged in here.<br>[11:25] Okay, let me<br>[11:29] um<br>[11:35] shouldn't I have Let me see.<br>[11:39] uh because I'm not logged in. Well, that<br>[11:42] can be solved very easily.<br>[11:45] I want to access this uh Twitter because<br>[11:49] I have here some<br>[11:54] resources. Well, actually I have them<br>[11:55] here as well. Yeah, that's what I wanted<br>[11:58] to<br>[12:00] to share with you.<br>[12:04] like these resources. I'm going to share<br>[12:07] them in the<br>[12:10] in the chat. Well, by the way,<br>[12:15] um<br>[12:17] I want to<br>[12:19] mention that I have<br>[12:22] published a new post in the developer<br>[12:25] blog which I think is uh is is really<br>[12:30] interesting because it<br>[12:34] it talks about how to combine like<br>[12:36] different APIs in WordPress to create<br>[12:39] effects or to create any behavior you<br>[12:43] want to to implement. And this is a<br>[12:47] really interesting use case because it<br>[12:49] covers<br>[12:51] both APIs<br>[12:53] that affect the edition experience and<br>[12:57] also the user experience.<br>[13:00] So we are<br>[13:04] we are implementing<br>[13:06] um<br>[13:08] the experience in both sides of the<br>[13:11] equation.<br>[13:13] So the effect is this.<br>[13:17] So we have for example a series of words<br>[13:21] separated by commas and I can select<br>[13:23] that text as a format and this is the<br>[13:26] addition experience. I can just okay I<br>[13:28] want this to be a word switcher effect.<br>[13:31] So each word will be detected will be<br>[13:34] isolated and will be presented in the<br>[13:36] form of this effect. So this is what<br>[13:39] this article is about and this um effect<br>[13:45] is done by leveraging the format API,<br>[13:50] the interactivity<br>[13:53] API, HTML API and also using JavaScript<br>[13:57] modules which we need to register and we<br>[14:00] which we need to build as a module. So<br>[14:03] there are some um<br>[14:06] some things to be taken into account and<br>[14:09] all of that is explained in this<br>[14:11] article. So yeah, I really recommend you<br>[14:14] I'm going to share this in the in the<br>[14:17] chat. Whoops. I'm going to<br>[14:21] share this in the chat.<br>[14:25] And without further ado, we can move on<br>[14:29] with the with the command pallet API.<br>[14:34] So the command pallet ai command pallet<br>[14:37] in case you don't know what I'm talking<br>[14:38] about is uh this when we are in the<br>[14:42] admin and now the in WordPress 6.9 the<br>[14:45] command pallet is available everywhere<br>[14:47] which means that is available here. This<br>[14:50] wasn't possible in WordPress 6.8 eight.<br>[14:54] And now since WordPress 6.9 this is um<br>[15:00] this is enabled and we can move around.<br>[15:04] We can go through we can go to a<br>[15:08] specific posts or specific pages<br>[15:12] or we can<br>[15:14] um go<br>[15:17] directly to a specific uh template.<br>[15:22] And from here maybe we can go to um<br>[15:29] we can go to editor<br>[15:33] appearance editor<br>[15:36] and yeah we can move around and the cool<br>[15:39] thing is that we can also create our own<br>[15:42] um we can create our own commands and<br>[15:46] this is what we are going to explore<br>[15:48] today.<br>[15:50] For example, one way to create a command<br>[15:53] is using this uh use command<br>[15:58] which is a React hook. And this React<br>[16:00] hook needs to be executed inside of our<br>[16:04] React component. And that React<br>[16:05] component needs to be um hydrated<br>[16:09] somehow into the DOM. And we need to<br>[16:11] find a way to to to do that.<br>[16:21] So let's explore this a little bit. Um<br>[16:26] what I want to<br>[16:32] what I want to move here is the studio<br>[16:34] where I have this<br>[16:36] um<br>[16:38] actually<br>[16:40] let's create a new site site um commands<br>[16:46] valid<br>[16:47] exploration<br>[16:53] I'm going to add the site. I'm going to<br>[16:56] make it<br>[16:59] I want to create a um<br>[17:04] like a local domain and we can do this<br>[17:08] here. If I edit site custom domain<br>[17:12] and commands valid expiration, I want to<br>[17:14] enable https.<br>[17:25] And with that<br>[17:27] what I want to do is I want to<br>[17:32] link the project that I have here under<br>[17:34] the folder common p valid exploration.<br>[17:38] So to do that, I'm going to come here.<br>[17:46] Um,<br>[17:48] running.<br>[17:52] I think it's because I created the<br>[17:55] domain. After that, I need to stop it<br>[17:59] and launch it again.<br>[18:03] Start.<br>[18:09] Okay. And now we have the site.<br>[18:14] And if I go to overview to iTerm,<br>[18:22] I'm going to go to uh to the plugins<br>[18:25] folder<br>[18:27] and I'm going to link the<br>[18:31] the project where I have all this<br>[18:33] initial exploration.<br>[18:36] Uh it's called commands uh valid no<br>[18:41] exploration command.<br>[18:44] valid exploration.<br>[18:48] So now that I have this project here, I<br>[18:52] should have it in plugins<br>[18:54] and I should be able to activate it and<br>[18:58] this<br>[19:02] um register this custom commands that I<br>[19:05] have created. So these are commands to<br>[19:07] access directly the the handbooks<br>[19:09] directly from the from the command<br>[19:11] pallet. So for example, if I click here,<br>[19:13] I go directly to the blockator handbook.<br>[19:16] Or if I click here, I go directly to the<br>[19:19] theme handbook.<br>[19:22] And the nice thing is that um I can look<br>[19:26] I can search for the words in the the<br>[19:30] title,<br>[19:32] but also I can add some keywords. For<br>[19:35] example, whenever I search for dogs,<br>[19:38] these results appear. So how have I done<br>[19:41] this? Um<br>[19:47] so this is how this is done. This is I<br>[19:50] think the easiest way to to register um<br>[19:53] a command.<br>[20:06] It seems that is offline.<br>[20:11] I'm not sure if I'm streaming right now<br>[20:13] or not<br>[20:17] because it appears offline OBS. Let me<br>[20:21] quickly check this. If I go to YouTube<br>[20:27] and I go to my channel.<br>[20:37] Yeah, it seems that this is streaming.<br>[20:41] Okay.<br>[20:44] Okay. Yeah. Back again.<br>[20:47] Back again.<br>[20:50] Yeah, this OBS software is is really<br>[20:52] strange. I<br>[20:55] I don't fully understand it to be<br>[20:57] honest. So, every from time to time I<br>[21:00] have like these little surprises that I<br>[21:02] have to I have to deal with. Well,<br>[21:05] anyway,<br>[21:07] um<br>[21:08] how these commands are registered. So,<br>[21:11] we can use the<br>[21:14] dispatch method of WordPress data. Um,<br>[21:21] WordPress data is the data layer of the<br>[21:27] of the<br>[21:30] stores that centralize the the data.<br>[21:37] If we come here,<br>[21:40] expect<br>[21:49] Okay, let me I'm going to close<br>[21:53] all the<br>[22:03] I think is if I come here to inspect and<br>[22:06] I go to redux<br>[22:09] here we can see the stores. So the<br>[22:12] stores are<br>[22:14] available. If we come here to the<br>[22:16] console and we check Dolbyp,<br>[22:21] we can see that there are a lot of<br>[22:24] objects and<br>[22:28] shared under the Dolby VP global object.<br>[22:31] So we can we have access to the API<br>[22:34] fetch uh function but also to the blocks<br>[22:39] object the block editor and all of them<br>[22:42] they have a thing called store<br>[22:49] and this store is the one that we can uh<br>[22:54] pass to<br>[22:56] Dolbyp data<br>[23:01] um<br>[23:03] to dispatch actions or to select data.<br>[23:08] If we come here to Redux, we can see<br>[23:11] here how there are different stores<br>[23:14] available. One of the stores we have is<br>[23:16] called commands. And here we can see we<br>[23:19] should see all the commands that are<br>[23:21] registered.<br>[23:23] And<br>[23:25] we should see here our<br>[23:29] own commands the ones that we have<br>[23:32] registered.<br>[23:34] Let me see if I can find them.<br>[23:39] Um<br>[23:43] what is the name? The name of is command<br>[23:47] API exploration.<br>[23:53] command and here here they are. Command<br>[23:55] API exploration docs block editor and<br>[24:00] whenever this command is called I<br>[24:04] trigger a specific callback which in our<br>[24:07] case is uh just a window open to the<br>[24:10] specific link according to this array of<br>[24:13] objects where I have defined all the uh<br>[24:17] data of the different handbooks.<br>[24:20] So what I do here is I loop over the<br>[24:24] array and for each object I register the<br>[24:27] command. How do I register the command?<br>[24:30] I dispatch an action which is register<br>[24:32] command of the command store.<br>[24:37] So we come here and we do commands.<br>[24:50] Um<br>[24:51] no, if I do if I do DVP data and then<br>[24:57] DVP<br>[24:59] commands um store<br>[25:08] If I do WP data this patch comment<br>[25:14] store, this should<br>[25:17] return<br>[25:19] a set of actions we can trigger to<br>[25:24] alter the data that is in the Redux<br>[25:29] store.<br>[25:31] And one of the actions is register<br>[25:33] command. So we do data dispatch the<br>[25:36] specific store in this case in the<br>[25:38] command store and register command and<br>[25:41] register command. If we check the<br>[25:43] documentation here<br>[25:49] register uh command.<br>[25:54] If we look for register command,<br>[25:59] we have here we have here the commands<br>[26:01] data register.<br>[26:06] Well, this is not really useful. So,<br>[26:08] let's go with the other result.<br>[26:19] Yeah, this is the information we need to<br>[26:20] pass to register a command. name, label,<br>[26:23] icon, call back, context, the context of<br>[26:25] the command and the keywords.<br>[26:32] So this is a way of registering a<br>[26:34] command.<br>[26:38] And um<br>[26:42] this is what I've done here.<br>[26:46] And this is a good way because if we<br>[26:48] don't need any<br>[26:51] thing that is super complex, this is<br>[26:53] good enough.<br>[26:56] But what happens if we need to interact<br>[27:00] with<br>[27:02] um<br>[27:05] other hooks and we want to use the hook<br>[27:10] way of registering a command. For that<br>[27:13] we have the use command hook.<br>[27:17] And<br>[27:21] and if we need that and for example if<br>[27:23] we need a models or um<br>[27:29] other effects that can be triggered uh<br>[27:33] from react. We need to<br>[27:37] find a way of<br>[27:40] um mounting manually a react um<br>[27:47] a react container and so this is<br>[27:51] properly hydrated into the dome.<br>[27:55] This is an example. So let's copy this.<br>[27:58] Let's comment this a little bit.<br>[28:04] For example,<br>[28:06] um we can call this<br>[28:09] latest<br>[28:12] posts.<br>[28:19] Okay. Yes.<br>[28:22] And I'm going to copy this<br>[28:38] Okay.<br>[28:42] And what I can do here is okay this<br>[28:45] latest posts and right now<br>[28:50] I'm going to move this logic to the<br>[28:52] index.<br>[29:02] I'm appending a specific DOM element and<br>[29:05] inside that do element I'm creating a<br>[29:08] root to render a specific<br>[29:10] um<br>[29:13] react component which is the one I'm<br>[29:15] going to import<br>[29:18] from here.<br>[29:22] I also need to<br>[29:26] I'm going to remove this<br>[29:30] and I'm going to export<br>[29:34] default<br>[29:37] function.<br>[29:39] This this is a<br>[29:43] a React component.<br>[29:45] What else? the dump ready. I'm going to<br>[29:48] move it to<br>[29:55] I'm going to move it to and uncreate<br>[29:57] root as well.<br>[30:00] And yeah, we should have<br>[30:04] we should have<br>[30:07] no latest<br>[30:10] post uh command<br>[30:15] post commands. Okay.<br>[30:18] So, how are we doing this?<br>[30:25] This is the<br>[30:28] React component that we are<br>[30:34] we are invoking. We are um triggering<br>[30:38] when the specific command is uh called<br>[30:41] is summoned.<br>[30:45] This react component has uh two states<br>[30:48] is open and set is open. Is open will be<br>[30:51] true or false depending if the specific<br>[30:54] uh model is rendered or not.<br>[31:04] So this um react component<br>[31:10] make use of the use command which is a<br>[31:13] hook available from the WordPress<br>[31:16] commands. And if we look for use<br>[31:18] command,<br>[31:21] we look for use command.<br>[31:26] We can see that<br>[31:30] attach a command to the command pallet<br>[31:32] used for static commands.<br>[31:41] Um<br>[31:43] but we need to<br>[31:48] appear this command<br>[31:51] this commands. Okay. If we look for use<br>[31:54] command, let me look for that in<br>[31:55] Gutenber.<br>[31:59] We look for Gutenber and we look for use<br>[32:02] command<br>[32:06] export hooks. Yeah, we can see that this<br>[32:09] is a hook hook. The hook use command<br>[32:16] and it's a hook. It uses this effect.<br>[32:19] So, we need to to to launch this from um<br>[32:23] from a React component.<br>[32:26] And that's why I'm doing this.<br>[32:29] That's why in order to render this<br>[32:33] React component that internally<br>[32:38] is uh making use of the hook use<br>[32:42] command.<br>[32:44] We are um<br>[32:47] what we are doing is via JavaScript we<br>[32:50] are creating a DOM element<br>[32:54] and<br>[32:56] we are hydrating that uh DOM element<br>[32:59] with<br>[33:01] my custom<br>[33:04] re component which is the one that is<br>[33:07] making use of the hook<br>[33:10] here<br>[33:12] and Here<br>[33:15] I can call all the react components and<br>[33:18] this react component uh latest post<br>[33:21] model is uh the one<br>[33:26] that<br>[33:29] uses other hooks like you select for<br>[33:33] example the idea let's um let's try we<br>[33:37] can go if we reload code.<br>[33:46] We can do um<br>[33:50] show latest posts.<br>[33:54] And here we can see a specific uh model<br>[33:57] window<br>[33:59] where we can go to the specific post<br>[34:09] and we can show uh<br>[34:13] show latest posts<br>[34:18] and we can go and edit the post. for<br>[34:20] example.<br>[34:26] So this is an strategy that I think it<br>[34:29] can work<br>[34:34] because this is a way to ensure that all<br>[34:37] command registered via hooks is um<br>[34:41] properly registered.<br>[34:48] no matter where this is executed.<br>[34:56] And what I'm doing here is okay, I'm<br>[34:58] using the use select which returns the<br>[35:03] post and is loading.<br>[35:09] This is the query I'm doing. I'm<br>[35:16] selecting<br>[35:19] from the core store which I have<br>[35:23] imported here. I'm using the get entity<br>[35:26] records and there is a good post in the<br>[35:30] developer blog about the get entity<br>[35:32] records. We go to<br>[35:39] well we have use entity records and get<br>[35:42] entity records. So I'm going to share<br>[35:44] this<br>[35:47] in the chat<br>[35:53] and we are getting the post and while<br>[35:56] this is loading the cool thing is that<br>[35:58] I'm showing a spinner and if it's not<br>[36:00] loading I'm h iterating over the<br>[36:05] different items uh retrieved which are<br>[36:08] the different the latest posts because I<br>[36:11] am uh um using this query<br>[36:16] post type post in the query and<br>[36:20] and I can close the the model.<br>[36:26] So this is<br>[36:32] any tips just started coding as a<br>[36:33] beginner. What language do you<br>[36:35] recommend? Wow, that's um it's an<br>[36:38] interesting question. Do you are you<br>[36:41] interested in in programming in in<br>[36:43] WordPress or just in in general?<br>[36:51] Okay. So we have here a model<br>[36:56] um component which we can import from<br>[37:00] spinner and then the external link.<br>[37:04] This is the<br>[37:10] Okay. In general,<br>[37:12] um, okay, so UB sounds is asking about a<br>[37:16] specific uh language.<br>[37:19] If you are starting, I would recommend<br>[37:21] to start with a programming language um,<br>[37:25] such as JavaScript or Python. I think<br>[37:28] those are the<br>[37:30] the easiest ones to learn and the ones<br>[37:34] you can do the most. uh from my<br>[37:36] experience both Python and JavaScript<br>[37:39] are pretty popular. There are a lot of<br>[37:42] um projects done in in in<br>[37:46] Python and JavaScript and and there are<br>[37:50] a lot of resources on the web. So yeah,<br>[37:53] that would be my recommendation and from<br>[37:55] there you can uh move and explore other<br>[38:00] languages uh such as uh yeah PHP or or<br>[38:05] any other also depending on what type of<br>[38:07] uh products you want to to create for<br>[38:11] the web for example. Hey Elliot, how you<br>[38:14] doing? Hi.<br>[38:19] We're talking about programming<br>[38:20] languages. It's a<br>[38:23] very open open big topic.<br>[38:30] What career paths do those offer? Um<br>[38:34] well these programming languages<br>[38:38] I think there is a lot of uh work for<br>[38:41] for these programming languages. And<br>[38:49] so for example, if you learn PHP um for<br>[38:54] WordPress related uh projects, I think<br>[38:57] there is a lot of uh<br>[39:01] a lot of jobs in that in that uh<br>[39:04] ecosystem. Um and also if you learn PHP<br>[39:09] and JavaScript which are like the most<br>[39:11] uh<br>[39:15] Yeah.<br>[39:17] Yeah. I agree.<br>[39:19] Actually is saying like I think every<br>[39:21] programming language offers path in<br>[39:23] every domain. Yes. Some are more<br>[39:24] dominant than others. Yeah.<br>[39:28] Yeah. From my perspective, I think that<br>[39:30] the JavaScript and Python are pretty<br>[39:32] popular. So that's like um um<br>[39:40] that's a good direction to start with.<br>[39:42] something. But yeah, from from there um<br>[39:47] it depends on what you're interested in<br>[39:50] like if you interested in developing<br>[39:53] games for example or web pages or or any<br>[39:57] other.<br>[39:59] Okay. So let's uh go back to our command<br>[40:03] and<br>[40:05] just to summarize we have um<br>[40:10] we have reviewed two ways of creating<br>[40:12] commands. The first one is the easiest<br>[40:15] one. Um yeah Elliot is saying choosing a<br>[40:19] single programming language is hard. I<br>[40:21] found that the best way to learn is to<br>[40:23] just build things and experiment with<br>[40:24] different ways of doing them. Yeah.<br>[40:27] Yeah. I agree. I agree.<br>[40:31] Do any of you have any um<br>[40:36] favorite programming language? Something<br>[40:38] you feel comfortable with or something<br>[40:40] that you would recommend? I mean um if<br>[40:43] someone is asking you this question,<br>[40:46] which programming language<br>[40:49] should I learn? Do you have like a a<br>[40:51] recommendation?<br>[40:54] For me it would be um<br>[40:58] it would be JavaScript actually<br>[41:02] that would be my my recommendation<br>[41:06] like to start with something because<br>[41:08] it's a language you can use for both the<br>[41:09] front end and the and the back end and<br>[41:12] it's pretty flexible.<br>[41:18] Taxil says, "I like JS and C++ even<br>[41:22] though I don't code in it." Yeah,<br>[41:31] there was this video the other day. I<br>[41:33] saw Yeah, says JS, HTML, CSS, and JST.<br>[41:38] Yeah, I think that combo is pretty<br>[41:40] especially for the web<br>[41:44] like understanding deeply JavaScript,<br>[41:47] HTML and CSS. It's very powerful. It's<br>[41:50] very powerful because with JS you can<br>[41:53] manage the behavior in the front end but<br>[41:57] also a lot of logic in the back end and<br>[42:00] understanding good markup and and CSS.<br>[42:04] Uh<br>[42:08] so Jubie says from what I observed is<br>[42:11] the most hirable or what do you think<br>[42:18] like a JavaScript Yeah, I would say for<br>[42:22] me I think JavaScript, Python, PHP are<br>[42:27] like good bets, are like good options.<br>[42:30] This is a matter of exploring them, see<br>[42:33] what you like most about them and then<br>[42:36] and continue<br>[42:38] doing them. The good thing is that<br>[42:40] nowadays with AI, you can really I I<br>[42:43] really like this current time we're<br>[42:46] living in because you can really<br>[42:49] you can really explore any language<br>[42:51] without having any idea and just let AI<br>[42:54] to to guide you through that. So you can<br>[42:56] say okay uh let's create something and<br>[43:00] guide me through every step of it and<br>[43:02] you can ask questions and it's like a a<br>[43:04] good way to to learn<br>[43:07] to learn things. Um,<br>[43:10] sometimes I think it's like a the<br>[43:14] feeling I have when I use Google Maps.<br>[43:18] AI is free tutori. Yeah, I agree. I<br>[43:21] agree. For example, when we use Google<br>[43:24] Maps, we go into a place we haven't been<br>[43:27] before and we just move around like if<br>[43:29] we live there because we can um<br>[43:34] we can go in a new town and we can just<br>[43:36] set an appointment at a specific time<br>[43:38] and we can just be like very tight tight<br>[43:43] time like um trusting the time the<br>[43:46] Google Maps is uh saying it's going to<br>[43:49] take and we can move around uh with uh<br>[43:53] going to addresses we<br>[43:57] haven't been there before. So yeah, it's<br>[44:00] like moving around places we are not<br>[44:03] familiar with and we we haven't been<br>[44:06] before. And for me AI<br>[44:09] um I feel it uh in a similar way. I can<br>[44:13] start uh working with um a programming<br>[44:16] language I don't know with a framework I<br>[44:19] don't know and I can just ask questions<br>[44:21] and I can learn as I I do think what do<br>[44:24] we all do before will maps<br>[44:28] I don't know I don't know<br>[44:30] because I I use it even if I know the<br>[44:33] the the<br>[44:36] way<br>[44:43] because sometimes yeah I<br>[44:48] um What other uh platform do you stream?<br>[44:53] I'm streaming in<br>[44:56] Twitch and<br>[45:01] Okay, you are from Twitch. I stream at<br>[45:05] the same time into Twitch and<br>[45:09] YouTube.<br>[45:10] So if we<br>[45:13] if you go to YouTube, I'm sharing here<br>[45:17] the my channel.<br>[45:25] So this is my channel and if you're<br>[45:29] interested in<br>[45:31] WordPress development, I have a lot of<br>[45:35] a lot of videos there from the streams<br>[45:39] that I<br>[45:41] that I do from time to time. I'm also<br>[45:44] pretty active in my blog.<br>[45:47] So I'm sharing that resource as well<br>[45:49] here.<br>[45:52] Um,<br>[45:53] what else?<br>[45:58] I'm also pretty active in GitHub and I<br>[46:04] have in GitHub uh<br>[46:07] a map of all the things I've been<br>[46:11] working on. So, yeah, that's another uh<br>[46:14] good uh reference for what I've been<br>[46:17] doing.<br>[46:19] Okay, let's go back to the commands.<br>[46:23] Two ways we have seen so far. Um,<br>[46:28] cool.<br>[46:30] Um,<br>[46:32] we have<br>[46:35] checked ways to register commands that<br>[46:39] work in all pages that work in both the<br>[46:42] admin dashboard and in the citator and<br>[46:44] in the pulsator.<br>[46:46] First way is this one<br>[46:51] this patch.<br>[46:53] Actually we can do a very<br>[46:59] a very quick<br>[47:01] test<br>[47:05] if we<br>[47:08] look if we go to my GitHub page. This is<br>[47:14] um this is something that I uh generate<br>[47:18] automatically every day. So this is<br>[47:20] really cool. The project is here. This<br>[47:23] is my GitHub because I have like<br>[47:26] different organizations in GitHub and<br>[47:30] this is the one that I use for WordPress<br>[47:32] development. And in this specific<br>[47:35] organization in the landing page of this<br>[47:37] organization, I have this uh list of<br>[47:40] resources that I<br>[47:43] that I like or that I'm working on. And<br>[47:46] for example, what I have here is a link<br>[47:48] to some guests. And<br>[47:53] what I want to show you here is that I<br>[47:56] have<br>[47:58] I have a Giz here<br>[48:02] which is a way to create a new command.<br>[48:05] I'm going to share this here.<br>[48:09] Okay. So the cool thing about this<br>[48:11] command is that we can copy.<br>[48:14] We can go to any<br>[48:17] WordPress installation.<br>[48:22] So if I<br>[48:25] type command K, I launch this command<br>[48:28] palid and if I type which is my name,<br>[48:33] there's no command. But<br>[48:37] if I copy and paste this, I can register<br>[48:40] a command using the same approach we<br>[48:44] have used here. The difference here is<br>[48:46] that we are using a build process. So we<br>[48:49] are importing the different libraries<br>[48:53] and generating a build version. And this<br>[48:55] is the one that we are loading. But here<br>[48:58] we are using directly the<br>[49:04] the packages that are<br>[49:07] um published in WordPress. So in<br>[49:09] WordPress the the data package is<br>[49:13] available as a property of the um WP<br>[49:18] global object. The same with the<br>[49:21] commands and<br>[49:24] a lot of other packages. So what we can<br>[49:26] do is directly<br>[49:29] call the dispatch method of the data<br>[49:32] package. We need to pass a specific<br>[49:35] store. This can be like the block store,<br>[49:37] the editor store. In this case, we're<br>[49:39] interested in the comments store. And um<br>[49:42] this dispatch<br>[49:44] method over a store, it returns a set of<br>[49:48] actions that we can execute. Um<br>[49:54] if we do this we can see that we get a<br>[49:57] lot of uh well a lot of uh a number of<br>[50:00] actions like register command and<br>[50:04] this register command we can use it to<br>[50:07] register a command. And if we uh do<br>[50:11] here, we can see how now we have this uh<br>[50:14] command, this custom command that what<br>[50:17] it does is redirect to to my web page.<br>[50:21] But this is a a pretty um<br>[50:25] good way to<br>[50:29] demonstrate how to register commands.<br>[50:32] Okay, so we have this method. Then we<br>[50:34] have this other method, latest posts.<br>[50:37] I'm thinking about the strategy used<br>[50:40] here. I'm not sure. I think it's fine. I<br>[50:42] don't think there<br>[50:45] I'm thinking about the architecture.<br>[50:48] So what we are doing is we are creating<br>[50:50] um a DOM element.<br>[50:54] So let's what we are doing is we are h<br>[50:58] when the DOM is ready we are creating a<br>[51:02] specific deep we are assigning that deep<br>[51:07] an ID we are appending down that to the<br>[51:11] body and then we are uh rendering or<br>[51:16] react component in that uh DOM element<br>[51:19] that we have created on the fly<br>[51:23] and The react component we are rendering<br>[51:25] is called latest post command which is<br>[51:28] this one and this command uh is a react<br>[51:32] component. So inside the react component<br>[51:34] we can use all the<br>[51:37] the different hooks like for example use<br>[51:39] state use command and this<br>[51:45] state variable we use it to<br>[51:52] to display or not this model window.<br>[51:58] can come here and say.<br>[52:02] So when we click<br>[52:06] recently did posts it displays<br>[52:11] um<br>[52:13] it displays the model window based on<br>[52:15] the value of this is open. But when we<br>[52:19] click here,<br>[52:22] we use set this open to false. The on<br>[52:25] close of that model<br>[52:29] uh this on close<br>[52:33] is the one that we pass to the model.<br>[52:36] And when we close and here we can make<br>[52:39] use of other post other hooks like for<br>[52:43] example um you select to get the list of<br>[52:46] posts which is um dynamically<br>[52:52] retrieved and from there we can<br>[52:56] um we have access to both the data and<br>[52:59] both the<br>[53:02] the is loading. Um<br>[53:06] if we come here we can reload. If we go<br>[53:10] to the network we can see this would be<br>[53:13] a fetch I think.<br>[53:17] We see latest<br>[53:19] posts.<br>[53:27] Look how this is triggering a lot of um<br>[53:33] lot of calls to the rest API. But in our<br>[53:36] case, if we do show latest posts,<br>[53:40] we can see how is triggering this rest<br>[53:44] API request via the<br>[53:48] this code.<br>[53:50] This code is triggering the get records<br>[53:54] is<br>[53:56] fetching the data via a rest API<br>[54:00] request.<br>[54:01] This is the data that is retrieved<br>[54:06] and we are displaying this. So yeah, I<br>[54:09] think is uh<br>[54:12] is fine<br>[54:14] because the use command<br>[54:22] this doesn't<br>[54:26] let me see um con command<br>[54:32] and<br>[54:34] console lock command. Let's see.<br>[54:36] I'm not sure if this returns something,<br>[54:38] but just uh<br>[54:45] no undefined. No, it doesn't return<br>[54:47] anything.<br>[54:49] But we can use it to uh to register a<br>[54:53] command. Okay, this is one option, the<br>[54:57] use command.<br>[55:09] Now, if we only want to register<br>[55:12] commands in the in the block editor,<br>[55:17] we can avoid this thing of um<br>[55:24] creating a DOM element and appending<br>[55:26] that DOM element to<br>[55:28] body and then rendering all React<br>[55:31] component in it because we can leverage<br>[55:36] the existing<br>[55:39] React system already rendered because<br>[55:43] the block editor and the post editor is<br>[55:47] just a big uh react application.<br>[55:51] So what we can do is use register plugin<br>[55:54] and the thing is that the thing is we<br>[55:57] need a way to render a react component.<br>[56:00] If we are in the block editor or in the<br>[56:02] post editor, we can leverage register<br>[56:04] plug-in. If we are not or if we want to<br>[56:07] ensure that this works in any page, we<br>[56:09] cannot h rely on this because for<br>[56:12] example in the in the main admin<br>[56:14] dashboard, this won't work. this won't<br>[56:17] work.<br>[56:21] So if our command is only meant for post<br>[56:24] page 18 experience, we can use the<br>[56:25] register plugin.<br>[56:30] So let's create here um<br>[56:35] copy post content.<br>[56:40] Copy post content.<br>[56:53] So let me see this<br>[56:55] um<br>[57:02] for all<br>[57:07] uh in the admin area<br>[57:15] and this is for all pages in the admin<br>[57:19] area. Um using hooks<br>[57:23] and this is h using<br>[57:28] dispatchers<br>[57:31] using a dispatcher.<br>[57:36] And now we are going to use<br>[57:41] we are going to use four uh pages in the<br>[57:46] block editor<br>[57:51] only in the<br>[57:54] block editor editor<br>[57:59] using um plugin render plugin Register<br>[58:08] plugin.<br>[58:11] Using register plugin and<br>[58:15] copy<br>[58:17] post content to people.<br>[58:29] And what I'm going to do is I'm going to<br>[58:32] import the specific React component and<br>[58:34] I'm going to register it here.<br>[58:37] So copy post content.<br>[58:42] This thing I'm going to do it.<br>[58:46] I'm going to export<br>[58:49] default<br>[58:52] function.<br>[58:56] I'm going to export default default<br>[59:06] default function<br>[59:10] post content and the register plugin<br>[59:15] I'll bring it here.<br>[59:25] So now we have a third way of<br>[59:27] registering commands<br>[59:31] which in this way is<br>[59:38] um we are using the register plugin way.<br>[59:44] Quick question. What's the extended<br>[59:46] proper what's the extended proper use<br>[59:49] case of reducer plug-in? Because if we<br>[59:51] just want to load it in the post editor,<br>[59:55] we can do a screen check in PHP while in<br>[59:57] queue in the JS, right? I'm not inclined<br>[60:00] with the JS at all. If it's not going to<br>[60:02] be used, let me see if I understand<br>[60:04] this. Um,<br>[60:11] if we just want to load it in the post<br>[60:13] editor,<br>[60:18] we can do a screen check in PHP.<br>[60:21] Yeah, I'm not sure how to do that. I I<br>[60:24] it rings a bell, but I'm not sure about<br>[60:26] how this would work and not burden<br>[60:29] client with the JS at all if it's not<br>[60:31] going to be used.<br>[60:36] I guess that there are different ways of<br>[60:38] doing the same. I think that um<br>[60:44] I think that you are right. Um you have<br>[60:48] some example of how to do maybe we can<br>[60:50] try that here. How to do a screen check<br>[60:53] in PHP.<br>[60:57] Um<br>[61:03] I I guess this could be another way and<br>[61:06] another um yeah maybe most more<br>[61:10] effective way or more<br>[61:12] uh performant way of doing that. Not<br>[61:15] loading the JS if we are not in the<br>[61:17] block editor.<br>[61:25] In this way we are just um<br>[61:33] in this way this is also not a bad way<br>[61:36] because register plug-in is only going<br>[61:37] to work. I mean register plug-in is uh<br>[61:40] going to be<br>[61:46] well we are importing the register<br>[61:48] plugin function. Yeah that will be the<br>[61:50] the<br>[61:51] and we yeah and we are importing the the<br>[61:54] JavaScript. Yeah, I know what you mean.<br>[61:56] Yeah, we don't need to load this extra<br>[61:58] JavaScript. That's not going to if<br>[62:01] that's not going to work.<br>[62:05] I believe the register plug-in will be<br>[62:07] useful if there are many plugins that<br>[62:09] are defined in JS and we want to<br>[62:11] selectively add particular commands to a<br>[62:13] specific screens.<br>[62:17] Yeah, I think there's also a specific<br>[62:20] context<br>[62:24] property for commands.<br>[62:31] The context the context of the command<br>[62:40] and it says static and dynamic commands<br>[62:43] can be contextual. This means that in a<br>[62:45] given context, for example, when<br>[62:46] navigating the citator or editing a<br>[62:49] template, some specific commands are<br>[62:52] given more priority and are visible as<br>[62:55] soon as you open the command pallet.<br>[62:57] Also, when typing the command pallet,<br>[62:59] these contextual commands are shown<br>[63:01] above the rest of the commands. Okay, at<br>[63:02] the moment, three contexts have been<br>[63:04] implemented. Site editor, this is the<br>[63:06] context that is set when you're<br>[63:08] navigating the site editor.<br>[63:10] Entity edit is the context that is set<br>[63:13] when you are editing a document template<br>[63:16] template part or<br>[63:18] um or page and block selection edit.<br>[63:22] Yeah, but this h it just prioritizes the<br>[63:26] command. So it doesn't mean that it's<br>[63:29] not going to be executed. Um<br>[63:34] but yeah in a specific screen the<br>[63:37] commands um<br>[63:40] of that context will be<br>[63:43] displayed directly when we uh click<br>[63:46] control K and also um when we look for<br>[63:51] that if there are several results it<br>[63:53] will be the first ones uh to appear<br>[63:58] as the usage of the command pallet<br>[64:00] expands more context will be added.<br>[64:04] Attaching a command or command loader to<br>[64:06] a given context is as simple as adding<br>[64:07] the context property with the right<br>[64:09] context value from the available context<br>[64:10] above to the use command or use command<br>[64:13] loader calls.<br>[64:15] So for example here in our use command<br>[64:22] we can say that this is um<br>[64:30] you're editing a component<br>[64:35] template.<br>[64:37] This is the context that is set when a<br>[64:38] block is selected. Uh okay, let's say we<br>[64:43] want to give this a site editor.<br>[64:46] We can say context<br>[64:53] site editor.<br>[64:56] So this is<br>[65:07] and in the site editor. Okay, if we go<br>[65:11] to the site editor now we have this<br>[65:15] this plugin here. If we go to the site<br>[65:18] editor<br>[65:20] now, if we if we click command K, we can<br>[65:24] see that the the first one that appears<br>[65:26] is the one. And if we um show<br>[65:32] no show,<br>[65:36] we can see that the first one in the<br>[65:40] uh results. But<br>[65:43] if it doesn't match any result, yeah, it<br>[65:45] disappears. But if there are several<br>[65:47] results, it appears the first one. Nice.<br>[65:56] Okay, let's continue with um<br>[66:01] the context pan is cool. Saves a lot of<br>[66:03] travel of else juggling. Yeah,<br>[66:08] there are um I was exploring this<br>[66:11] morning. There are several um issues<br>[66:15] opened in Gutenberg. Let me see if I can<br>[66:17] find some of them.<br>[66:20] Um,<br>[66:23] for example,<br>[66:35] this is one.<br>[66:40] This is the one that I was exploring<br>[66:43] this morning.<br>[66:48] This is another one which I think is in<br>[66:51] the line of what you're saying.<br>[67:04] No, this is another one I was referring<br>[67:07] to. Um<br>[67:16] Yeah, the thing is that as we add more<br>[67:19] custom commands, um there must be some<br>[67:23] ways to<br>[67:25] identify<br>[67:28] like to group them. So this is one<br>[67:30] solution that was proposed like to add<br>[67:34] the like a category or a group or the<br>[67:36] plugin from where this is registered.<br>[67:40] That would be really cool.<br>[67:43] and<br>[67:50] by adding an action<br>[67:53] and the context for each.<br>[67:59] And what else do we have?<br>[68:11] consider more context than<br>[68:21] there was<br>[68:24] yeah this<br>[68:26] issue<br>[68:28] I'm sharing this in the in the chat<br>[68:35] and there was Another one with a lot of<br>[68:38] Let me see if I can find it.<br>[68:44] Ah, this one.<br>[68:46] Command pallet overview. This one.<br>[68:55] Oops.<br>[69:00] Yeah, these are like the different This<br>[69:02] is the one I was I wanted to to share.<br>[69:05] This is like the all the ideas and and<br>[69:08] some of them have been already<br>[69:10] implemented<br>[69:12] but some of the ideas to um for the<br>[69:15] command pallet and some of them they<br>[69:17] have to do with the accessibility<br>[69:20] um yeah for example this one allow<br>[69:23] hooking into command pallet commands and<br>[69:25] command loaders<br>[69:27] and<br>[69:32] and how to group Um<br>[69:37] I would really like something like um<br>[69:41] I wanted to explore that.<br>[69:46] Um,<br>[69:48] so my expiration could be<br>[69:55] um<br>[69:59] having a way to<br>[70:02] well actually my my explanation would be<br>[70:05] if I<br>[70:07] register commands like this that I have<br>[70:10] a way to see a description of the<br>[70:14] command maybe in the form of a tool tip.<br>[70:17] For me, it would be great if<br>[70:20] I<br>[70:23] keep the mouse in a command for maybe<br>[70:28] more than 3 seconds or 5 seconds. I get<br>[70:31] a tool tip here<br>[70:33] explaining<br>[70:36] in detail what the command is uh going<br>[70:38] to do. But in order to do that I need I<br>[70:41] think we need to um this is not<br>[70:44] something that we can do from a plug-in.<br>[70:46] This is something that we need to<br>[70:49] change the main engine of registering<br>[70:52] commands.<br>[70:55] H but this could be this could be a nice<br>[70:58] a nice addition.<br>[71:01] I'd like to explore that.<br>[71:05] Okay, let's continue. um register<br>[71:08] commands only in the block editor. So in<br>[71:11] our exploration we are using the<br>[71:14] register plugin because we know the<br>[71:15] register plug-in is only going to be<br>[71:18] executed in the<br>[71:22] in the post um<br>[71:26] in the post editor. Also here we are<br>[71:29] doing um<br>[71:36] we are doing some um<br>[71:39] some filters<br>[71:43] but yeah first let's<br>[71:45] let's see if this is registered<br>[71:47] properly.<br>[71:50] We can go<br>[71:53] here<br>[71:55] and we can do<br>[71:59] copy post content to the clipboard. And<br>[72:02] now if we come here we have the the<br>[72:06] content nice.<br>[72:11] So how we can do that? So we have um<br>[72:16] used a hook but in this case we don't<br>[72:19] need to emulate a react um because it<br>[72:23] doesn't make in this case it doesn't<br>[72:25] make sense that we copy the content from<br>[72:28] the admin dashboard. This command only<br>[72:31] makes sense here and what we can do is<br>[72:34] add a context like we did with the other<br>[72:37] thing. Maybe we can also do here context<br>[72:40] edit post because in this case it makes<br>[72:42] a lot of sense. So maybe reload<br>[72:49] and we have commands to go to the to the<br>[72:54] code<br>[72:55] open code editor.<br>[72:58] And here we have a command now to copy<br>[73:02] the content to the clipboard.<br>[73:09] What else? Uh<br>[73:11] now that this is is correct post let me<br>[73:14] check the documentation again.<br>[73:20] Let me check the documentation.<br>[73:23] No is entity edit<br>[73:28] context entity edit.<br>[73:32] Now, in theory, if we<br>[73:40] No.<br>[73:57] If I click<br>[74:01] control K or command Kh<br>[74:15] this is uh<br>[74:18] the context that is said when you are<br>[74:20] editing. Okay. So template template part<br>[74:22] or page but there is no entity edit for<br>[74:24] a post. That's interesting.<br>[74:28] That's interesting.<br>[74:31] So let's try this with a page.<br>[74:36] If we go to a page<br>[74:43] and we edit a page like for example this<br>[74:46] one.<br>[74:49] Um,<br>[74:59] so it's probably registered, but it's<br>[75:01] not really<br>[75:04] the context here is not really working.<br>[75:10] And if we go to a template<br>[75:22] And here, so it's not really a page.<br>[75:26] It's only templates.<br>[75:29] It's only a template because here is<br>[75:32] indeed<br>[75:37] being displayed as um<br>[75:41] so the context is working because it's<br>[75:42] being displayed as the default or the<br>[75:44] most important command for this context.<br>[75:49] But if we go to page or post is not<br>[75:51] doing that.<br>[75:57] So yeah, that's good to know. and block<br>[75:59] selection edit. This is the context that<br>[76:01] is set when a block is selected.<br>[76:08] Are there more contexts? Okay, let's<br>[76:10] check that because maybe maybe this is<br>[76:12] not updated.<br>[76:15] If we come here to Gutenberg block<br>[76:17] selection edit<br>[76:20] this readme<br>[76:22] just set command context.<br>[76:28] So yeah, right now there are only this<br>[76:29] one. Site editor, entity edit,<br>[76:36] a canvas edit.<br>[76:42] Um I'm going to ask<br>[76:50] um can I ask copilot about this?<br>[77:01] Um,<br>[77:05] in which um is<br>[77:08] will this be uh triggered in when<br>[77:13] editing a post<br>[77:16] or page?<br>[77:38] Okay, we need to investigate further.<br>[77:41] It's a rabbit hole. So, let's uh let's<br>[77:45] avoid it.<br>[77:48] Okay. So this is the the third case. We<br>[77:52] are<br>[77:53] we are<br>[77:55] registering a<br>[77:58] command only for the block editor which<br>[78:02] can be either the<br>[78:05] post editor or the site editor.<br>[78:18] And we are also leveraging the notice<br>[78:25] store. Okay. To start closing things.<br>[78:31] So here if I do<br>[78:34] copy<br>[78:37] post content copied to the clipboard.<br>[78:45] So it's very it's very simple. We can we<br>[78:48] are leveraging this um<br>[78:51] native uh methods of the the browser<br>[78:54] navigator clipboard<br>[78:56] write text content and the content we<br>[78:59] are getting it for from a selection to a<br>[79:04] specific uh store which is core editor.<br>[79:07] But maybe we can also say here um import<br>[79:12] store as editor store and maybe we can<br>[79:16] do also this here. So when we reload and<br>[79:21] we say<br>[79:23] copy post uh from clipboard<br>[79:28] we have this here. Nice. Nice.<br>[79:37] Okay, this is a third case.<br>[79:47] So this um<br>[79:51] command is registered for all the<br>[79:57] places where register plug-in works.<br>[80:00] That can be site editor, post editor,<br>[80:04] page editor, whatever. But what if we<br>[80:07] want to be more specific and we want to<br>[80:13] maybe<br>[80:16] um<br>[80:19] register the command or or make the<br>[80:22] command available only if we are in the<br>[80:25] the post editor for example. And for<br>[80:28] that we have this example here which we<br>[80:32] are to comment right now.<br>[80:43] This is block usage model.<br>[80:51] Block usage<br>[80:59] And what I'm going to do is<br>[81:02] export the full function.<br>[81:15] We import the React component and we<br>[81:18] register the plug-in<br>[81:23] only in the block editor. This won't<br>[81:26] work in the site editor. So how are we<br>[81:28] doing this?<br>[81:33] So the React component we are rendering<br>[81:37] is this one and the strategy is similar.<br>[81:41] We have a model window which we are<br>[81:44] controlling<br>[81:46] with<br>[82:08] this open true. And we do the same. We<br>[82:11] just um trigger this block usage model<br>[82:14] or not depending on the value of the is<br>[82:17] open.<br>[82:19] And we close it with the set is open<br>[82:22] false. Okay. And block usage model is<br>[82:25] this one that receives the on close.<br>[82:30] We get the<br>[82:33] the blocks<br>[82:36] of the current uh document.<br>[82:41] And we what what we want to do is to<br>[82:45] count the use of blocks in the current<br>[82:49] uh document. So for that we have this<br>[82:52] logic that goes through each block<br>[82:57] and just counts the<br>[83:05] the times each blocks used across the<br>[83:08] document. And then we<br>[83:10] um<br>[83:12] return the model<br>[83:17] and they use<br>[83:29] and the use block usage<br>[83:32] command.<br>[83:53] Show block usage.<br>[83:57] Ah, okay. And this is a command loader<br>[84:00] and they use common loader<br>[84:04] and let me see use command loader.<br>[84:10] Use command loader.<br>[84:20] and use command loader<br>[84:30] and<br>[84:32] this command<br>[84:36] attach a command loader to the command<br>[84:38] pallet used for dynamic uh commands.<br>[84:47] So maybe in this case<br>[84:56] we can do<br>[85:06] I know in this case we're using a a<br>[85:08] model<br>[85:09] and the block usage.<br>[85:13] Okay, so use block usage command. This<br>[85:16] is the the hook<br>[85:18] that register the commands.<br>[85:42] So we register the command.<br>[86:00] Well, this is I don't think this is<br>[86:02] really well structured.<br>[86:04] I need to improve this.<br>[86:07] Okay, let's analyze this.<br>[86:12] We do a selection using the use select<br>[86:16] hook and we pass the select um method<br>[86:20] and we get different information on<br>[86:22] different stores like the post type of<br>[86:24] the post type, the post ID from editor<br>[86:28] store.<br>[86:31] um<br>[86:33] the post type object<br>[86:36] from cor store and we return if we are<br>[86:39] in the post editor<br>[86:46] or not. The viewable. This is a property<br>[86:48] that is interesting<br>[86:51] because yeah, the viewable property in<br>[86:55] the snippet above code determines<br>[86:57] whether the current post type has a<br>[87:00] public facing edit screen in the<br>[87:02] WordPress admin interface.<br>[87:05] Yeah, because there are several post<br>[87:06] types that doesn't have um<br>[87:10] for example global styles I think is a<br>[87:12] is a post type.<br>[87:15] Um<br>[87:18] I think I have a guest somewhere<br>[87:22] to see um<br>[87:28] the different post types.<br>[87:37] Custom blocks registered.<br>[87:39] Get all items. All post types.<br>[87:50] some block registers.<br>[87:52] No, I don't have here.<br>[87:55] Um,<br>[87:57] but yeah, there are different post<br>[87:58] types.<br>[88:05] But for example, post types that are<br>[88:08] viewable<br>[88:14] Exactly. Yeah.<br>[88:19] Yeah. Yeah. No, it's um Yeah. Says it<br>[88:24] shows whether it has an editor screen<br>[88:26] exactly and not whether we are currently<br>[88:28] the in the editor screen exactly. So um<br>[88:38] we can select the current uh post type,<br>[88:41] the post ID<br>[88:44] and<br>[88:46] but the post type can not be something<br>[88:49] that can be viewable.<br>[88:52] Um<br>[88:54] so with this we are in theory we are<br>[88:58] restricting the access to just uh<br>[89:02] editing a post or editing a page. This<br>[89:05] good<br>[89:07] exclude um<br>[89:15] a template or template part<br>[89:18] viewable<br>[89:20] like whatever we are editing it can be<br>[89:22] viewable directly in the front end<br>[89:24] that's that's how I understand it<br>[89:26] which can be only our posts or pages but<br>[89:30] for example if we edit our template or<br>[89:32] our template part that cannot be<br>[89:35] directly viewed. This is used as an<br>[89:37] internal<br>[89:39] um<br>[89:41] internal piece for generating the final<br>[89:44] render of the page.<br>[89:46] Okay.<br>[89:51] Um<br>[89:54] select from cross store if the user can<br>[89:56] update. Okay. If the user can edit posts<br>[90:00] and the we are in either a post or a<br>[90:04] page,<br>[90:06] we register the command<br>[90:15] commands push.<br>[90:21] Okay, this is a bit uh different because<br>[90:24] command loader<br>[90:26] receives an array of commands even when<br>[90:30] we are here only just adding one command<br>[90:35] commands push.<br>[90:37] Um<br>[90:42] and what we are doing here is open model<br>[90:51] Uh yeah,<br>[90:56] this works but I don't really like the<br>[90:58] how this is structured because there are<br>[91:00] some dependencies here depends on this<br>[91:02] and this is set to null.<br>[91:08] Um,<br>[91:11] I need to think of a better way doing<br>[91:14] this. How can we improve this?<br>[91:20] This is the hook that is<br>[91:24] being called here.<br>[91:32] And the callback<br>[91:41] And the call back.<br>[91:48] The callback needs to<br>[91:53] needs to execute something. Um<br>[92:01] but we are here in a we are in a react<br>[92:05] environment. So<br>[92:10] maybe<br>[92:12] we can um<br>[92:21] is there a way to to render a React<br>[92:24] component?<br>[92:26] Yeah, we don't really. So this is a<br>[92:29] hook.<br>[92:33] Okay, let's ask um cloud code about<br>[92:36] this. Let's see if we can if we can<br>[92:39] improve this code. Okay.<br>[92:44] Um<br>[92:50] okay,<br>[92:52] I'm going to be honest with you, CL. Um<br>[92:54] I don't like the way this code is<br>[92:59] structured.<br>[93:03] Because um<br>[93:09] because block<br>[93:13] is a comment. Um<br>[93:16] sets<br>[93:18] the value<br>[93:21] of open model<br>[93:26] which is<br>[93:27] initialized.<br>[93:29] initialized<br>[93:32] outside of the function<br>[93:36] and<br>[93:46] I'm going to try a new toy that is<br>[93:49] called monologue.<br>[93:54] Okay. Monologue<br>[93:56] is the system<br>[94:01] we can use two. Let me see.<br>[94:09] Okay.<br>[94:11] I don't like the way this code is<br>[94:14] structured because for example the block<br>[94:17] usage command function<br>[94:21] sets the open model<br>[94:24] function that is initialized<br>[94:27] outside of the function<br>[94:31] and also is used inside of the callback<br>[94:38] used in the object<br>[94:43] added to the command array. So is there<br>[94:46] any way we can<br>[94:51] make<br>[94:54] this better.<br>[94:59] Okay, let's see if um<br>[95:03] which ideas.<br>[95:13] Yeah.<br>[95:19] Uh, use context using React context.<br>[95:40] Okay.<br>[95:51] Um, use context.<br>[96:08] Uh, okay.<br>[96:12] So, use context<br>[96:19] Block usage model.<br>[96:31] Open model.<br>[96:45] Okay. Block usage context uh provider<br>[96:50] value set is this open true.<br>[97:12] Okay. use. Well, first let's see if this<br>[97:14] works.<br>[97:20] Let's see if this works.<br>[97:36] So here it's fine that it's not um<br>[97:40] available. But if we go to a page, it<br>[97:43] should be there.<br>[98:01] Um, or maybe say only in the post. Let<br>[98:04] me see.<br>[98:18] Show block usage.<br>[98:29] Yeah. No, this is not working.<br>[98:32] Open model is not a function.<br>[98:46] Isn't there a way to go back?<br>[99:03] So if we go we come here<br>[99:10] show blog usage<br>[99:15] and if we go to a page<br>[99:23] we can show block usage<br>[99:31] only in the Post<br>[99:41] only.<br>[99:43] Okay, this is this part. Can user edit<br>[99:46] post<br>[100:04] is post editor.<br>[100:14] Okay, let me see if I console log.<br>[100:25] Console log.<br>[100:55] post type page.<br>[101:13] Post type view is true.<br>[101:44] If I do console log disposiator and can<br>[101:48] use edit post,<br>[102:01] can you That edit post here is<br>[102:03] undefined.<br>[102:13] Uh I can just update.<br>[102:21] So the first one is true but it's<br>[102:23] because of the second one. So in the<br>[102:25] page<br>[102:29] okay it's because of the second one but<br>[102:31] if we come here<br>[102:42] okay<br>[102:49] can youer update<br>[102:53] post.<br>[102:58] Um,<br>[103:08] I don't really understand this. Can you<br>[103:12] say edit post?<br>[103:17] Why this is only triggered in the<br>[103:20] post editor as true?<br>[103:25] So this is clear. This is that we are in<br>[103:28] a post type that has in a post type.<br>[103:39] We are in a post type that has a<br>[103:44] um<br>[103:46] an screen. Yeah. viewable,<br>[103:49] but<br>[103:52] the post ID,<br>[104:01] let me see. Um,<br>[104:12] okay. And why this return<br>[104:18] Okay. Why can user edit post return true<br>[104:23] only when we are editing a post in the<br>[104:27] post editor<br>[104:30] because it seems that we are checking if<br>[104:34] the user can update the<br>[104:37] post<br>[104:39] but that's also the case for a page. I<br>[104:44] mean the user can also edit a page.<br>[104:47] So yeah, can you explain me why can user<br>[104:50] edit post returns true only<br>[104:56] when we are in the post editor? We are<br>[104:59] editing a post.<br>[105:09] I don't know if clo<br>[105:17] okay. This specifically checks if the<br>[105:19] user can update posts the post type not<br>[105:22] pages. Okay. That's why it returns true<br>[105:25] only when editing a post. The issue is<br>[105:27] that can user<br>[105:30] it's hard to check the post post when<br>[105:32] you are editing a page<br>[105:39] when you editing.<br>[105:55] Okay. Yeah. Uh I don't understand very<br>[105:59] well the logic behind this. Uh can user<br>[106:03] Let me see if Let's dive in a little bit<br>[106:07] more. If we go to the<br>[106:11] we go well actually we can come here and<br>[106:14] say locator handbook<br>[106:18] and we can look for can user<br>[106:22] which is incore data.<br>[106:33] returns whether the current user can<br>[106:35] perform the given action on the given<br>[106:37] red resource. Calling this may trigger<br>[106:38] an options request of recip.<br>[107:12] Okay. Okay. I need to think more about<br>[107:15] this. The thing is that with this filter<br>[107:18] we limit only the<br>[107:21] addition in the post editor<br>[107:26] and um only in that case we are<br>[107:29] registering this because this is the<br>[107:32] hook that returns this object.<br>[107:36] of commands and it's loading false.<br>[107:40] So just common loader is<br>[107:45] and with that command register<br>[107:54] we uh block usage model.<br>[108:11] We trigger this<br>[108:15] and um<br>[108:23] we trigger this. Um,<br>[108:28] okay. I need to think more about this<br>[108:30] example to see if uh I want to clarify<br>[108:34] two things. I want to clarify this.<br>[108:37] I'll think more about this and I also<br>[108:40] want to clarify<br>[108:42] how this hook<br>[108:45] is interacting with this model window<br>[108:48] because right now it's not super clear<br>[108:50] to me. Okay,<br>[108:52] perfect. I think we can<br>[108:56] uh finish the session.<br>[109:00] Hope it's been helpful.<br>[109:04] And yeah, I think this is the last<br>[109:06] session of the year because I'm going on<br>[109:08] holidays.<br>[109:10] So<br>[109:14] yeah, let me give you a reminder of<br>[109:19] my YouTube channel.<br>[109:23] because<br>[109:25] I have done a lot of streams this year.<br>[109:30] There you have all the streams that I<br>[109:32] have done.<br>[109:35] And also if you go to<br>[109:39] my streams<br>[109:43] repository<br>[109:45] there you can find all the details<br>[109:50] all the details of the<br>[109:54] streams that I have done during this<br>[109:55] year that you can find the resources<br>[109:57] that we've been using the<br>[110:02] the projects<br>[110:04] the different diagrams and all of that.<br>[110:09] So yeah, we can call it a year. Um hope<br>[110:12] you have a great holiday that you take<br>[110:15] rest and<br>[110:19] and yeah uh see you next year. Let me<br>[110:23] know via Twitter or you can also<br>[110:28] leave your ideas here in discussions. I<br>[110:30] have a conversation open for ideas for<br>[110:33] streams.<br>[110:34] So, leave here your ideas for the<br>[110:37] streams in case you would like me to<br>[110:41] to cover some specific topic. Okay,<br>[110:44] guys. Hope you're doing fine and yeah,<br>[110:46] see you see you all next year. Bye.
<!-- deep-read:sections end -->
[[3. Resources/Readwise/Full Document Contents/Articles/Creating Commands for the Commands Palette|Full Document Contents]]
## Document Notes
---
tags: #wordpress #command-palette #gutenberg #developer-tools #react-hooks
author: Mario Santos
source: YouTube Live Stream
reference: [https://www.youtube.com/watch?v=ETqUp0UXH0k]
date created: 2024-12-19 10:30
---
# ๐ท๏ธ Title: Creating commands for the Commands Palette
## ๐งฐ Action Inbox
- [H1] Implement handbook quick access commands โ use WP.data.dispatch for simple navigation #commands
- [H2] Create modal-based commands with React hooks โ mount React components manually #react-integration
- [H3] Add contextual commands for block editor โ use register_plugin for editor-specific features #block-editor
## ๐งญ Table of Contents
- [[#๐ Summary]]
- [[#๐ Main Content]]
- [[#๐๏ธ Notes]]
- [[#๐ References]]
- [[#๐ฃ๏ธ Paraphrase]]
- [[#๐ฐ Newsletter]]
- [[#โ
Action Items]]
- [[#๐งช Hypotheses]]
- [[#๐ Methodology]]
- [[#โ Questions]]
- [[#๐ฎ Future Research]]
- [[#๐ก Implications]]
- [[#๐ง Learning Styles Assessment]]
- [[#๐ Accessibility Assessment]]
- [[#๐ DEIB Assessment]]
- [[#โ
Logical Validity]]
- [[#๐ก๏ธ DARVO Analysis]]
- [[#๐ฏ Conclusion]]
### ๐ References
- [WordPress Developer Blog](https://developer.wordpress.org/news/)
- [Mario's GitHub](https://github.com/WordPress)
- [Stream Resources Repository](https://github.com/WordPress/streams)
## ๐ Summary
- WordPress 6.9 expanded command palette availability from block editor only to entire admin area
- Three main approaches for creating custom commands: WP.data.dispatch, React hooks with manual mounting, and register_plugin for editor contexts
- Commands can be contextual (site-editor, entity-edit, block-selection-edit) for better UX prioritization
- Challenges exist with React hooks requiring React environment while admin pages may lack this
## ๐ Main Content
WordPress 6.9 introduced a significant expansion of the command palette, making it available throughout the entire admin interface rather than just within the block and site editors. This creates new opportunities but also technical challenges for developers creating custom commands.
The core challenge stems from WordPress's data layer architecture. Many helper functions for command creation are React hooks that require a React environment to function. However, traditional admin pages outside the editor don't provide this React context, necessitating creative solutions for universal command compatibility.
Three distinct approaches have emerged for command creation, each suited to different use cases and technical requirements. The choice depends on where commands need to function and what level of interactivity is required.
## ๐๏ธ Notes
#### โฑ๏ธ [00:00](https://youtu.be/ETqUp0UXH0k?t=0) โ [H1] Session introduction and context
- Key idea: Live coding session exploring command palette development
- Evidence: "WordPress 6.9 the command palette is available everywhere"
#### โฑ๏ธ [05:23](https://youtu.be/ETqUp0UXH0k?t=323) โ [H2] Command palette expansion in WordPress 6.9
- Key idea: Command palette now works beyond just editors
- Evidence: "Before WordPress 6.9 the common palette was only available in the block editor"
#### โฑ๏ธ [08:45](https://youtu.be/ETqUp0UXH0k?t=525) โ [H3] React hooks challenge outside editor context
- Key idea: Hooks require React environment not always available
- Evidence: "These hooks can only be executed inside React components"
#### โฑ๏ธ [12:30](https://youtu.be/ETqUp0UXH0k?t=750) โ [H1] First approach: Direct dispatch method
- Key idea: Use WP.data.dispatch for simple command registration
- Evidence: "We can use the dispatch method of WordPress data"
#### โฑ๏ธ [18:15](https://youtu.be/ETqUp0UXH0k?t=1095) โ [H2] Demonstrating handbook navigation commands
- Key idea: Register commands to access WordPress handbooks directly
- Evidence: "Commands to access directly the handbooks directly from the command palette"
#### โฑ๏ธ [25:40](https://youtu.be/ETqUp0UXH0k?t=1540) โ [H2] Redux store inspection for commands
- Key idea: Command store visible in Redux DevTools
- Evidence: "One of the stores we have is called commands"
#### โฑ๏ธ [32:10](https://youtu.be/ETqUp0UXH0k?t=1930) โ [H1] Second approach: useCommand hook with manual React mounting
- Key idea: Create DOM element and render React component for hook usage
- Evidence: "We need to find a way of mounting manually a react container"
#### โฑ๏ธ [38:50](https://youtu.be/ETqUp0UXH0k?t=2330) โ [H2] Latest posts modal command demonstration
- Key idea: Modal interface for browsing and navigating to recent posts
- Evidence: "We can go to the specific post and we can show latest posts"
#### โฑ๏ธ [45:20](https://youtu.be/ETqUp0UXH0k?t=2720) โ [H3] Using useSelect hook for data fetching
- Key idea: Leverage WordPress data layer for dynamic content
- Evidence: "I'm using the useSelect which returns the post and is loading"
#### โฑ๏ธ [52:15](https://youtu.be/ETqUp0UXH0k?t=3135) โ [H1] Third approach: register_plugin for editor contexts
- Key idea: Use existing React environment in block editor
- Evidence: "If we are in the block editor we can leverage register plugin"
#### โฑ๏ธ [58:30](https://youtu.be/ETqUp0UXH0k?t=3510) โ [H2] Contextual commands and prioritization
- Key idea: Commands can be contextualized for better UX
- Evidence: "Commands can be contextual. This means that in a given context some specific commands are given more priority"
#### โฑ๏ธ [64:45](https://youtu.be/ETqUp0UXH0k?t=3885) โ [H2] Copy post content command implementation
- Key idea: Editor-specific command using clipboard API
- Evidence: "navigator clipboard write text content"
#### โฑ๏ธ [71:20](https://youtu.be/ETqUp0UXH0k?t=4280) โ [H3] Block usage analysis command
- Key idea: Dynamic command loader for analyzing block usage
- Evidence: "useCommandLoader used for dynamic commands"
#### โฑ๏ธ [78:10](https://youtu.be/ETqUp0UXH0k?t=4690) โ [H2] Context restrictions and user permissions
- Key idea: Commands can be restricted based on editing context
- Evidence: "canUser edit post returns true only when editing a post"
## ๐ References
- [WordPress Command Palette Documentation](https://developer.wordpress.org/block-editor/reference-guides/data/data-commands/)
- [Gutenberg Repository](https://github.com/WordPress/gutenberg)
- [WordPress Data Package](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-data/)
## ๐ฃ๏ธ Paraphrase
- WordPress 6.9 brought command palette functionality to all admin pages, not just editors, creating new development opportunities
- Three main patterns exist for command creation: simple dispatch calls, React hook mounting, and editor plugin registration
- Commands can be made contextual to appear first in relevant editing environments like site editor or block selection
## ๐ฐ Newsletter
**WordPress Command Palette Gets Major Expansion**
WordPress 6.9 has opened exciting new possibilities for developer productivity with the command palette now available throughout the entire admin interface. This expansion means you can create custom commands that work everywhere from the dashboard to post listings.
**Key Development Approaches:**
- **Simple Navigation**: Use `WP.data.dispatch()` for basic commands like handbook links
- **Interactive Modals**: Mount React components manually for complex interfaces
- **Editor Integration**: Leverage `register_plugin()` for block editor specific features
The contextual command system is particularly clever - your editor commands automatically get priority when relevant, creating a more intuitive user experience.
**Next Steps**: Start with simple navigation commands using the dispatch method, then explore React integration as your needs grow complex.
Resources: [Developer Docs](https://developer.wordpress.org/), [Command API Reference](https://developer.wordpress.org/block-editor/reference-guides/data/data-commands/), [Live Coding Archive](https://youtube.com/@mariosantos)
## โ
Action Items
#### WordPress
- Core: Investigate additional command contexts beyond site-editor, entity-edit, block-selection-edit
- Core: Consider command grouping/categorization for better organization
- Core: Explore command descriptions and tooltips for enhanced UX
- Documentation: Create comprehensive command palette development guide
- Documentation: Document screen checking in PHP for conditional JS loading
#### Community
- Contributors: Share command palette plugins and use cases
- Contributors: Test command palette accessibility across different admin contexts
- Maintainers: Evaluate command palette integration opportunities in existing plugins
## ๐งช Hypotheses
- Command palette usage will increase developer productivity in WordPress admin workflows
- Contextual commands will reduce cognitive load by showing relevant options first
- Manual React mounting approach will become standard pattern for complex commands
- Screen-based PHP loading checks will improve performance over universal JS loading
### ๐ Methodology
- Create test commands using all three approaches and measure implementation complexity
- User testing to compare navigation efficiency with and without custom commands
- Performance analysis of React mounting vs dispatch methods
- Accessibility testing across different admin page contexts
### โ Questions
- How can we improve the architecture for commands requiring React hooks outside editor contexts?
- What additional command contexts would be most valuable for developers?
- How should commands be grouped or categorized as the ecosystem grows?
### ๐ฎ Future Research
- Command palette performance optimization techniques
- Integration patterns with existing WordPress admin workflows
- Accessibility best practices for modal-based commands
### ๐ก Implications
- Practice: Command palette becomes essential skill for WordPress developers
- Policy: May influence WordPress admin interface design patterns
- Security: Custom commands need careful permission checking and validation
- Education: Training needed on React integration patterns outside traditional editor context
### ๐ง Learning Styles Assessment
Reading level estimate: Grade 12
#### ๐ Visual learners
- Present: Code examples, command palette screenshots, Redux DevTools inspection
- Improve: Architecture diagrams showing different command registration flows
#### ๐ Aural learners
- Present: Live coding explanation with verbal narration
- Improve: Audio summary of key concepts and decision points
#### ๐ฃ๏ธ Verbal learners
- Present: Clear explanations of technical terms, API analogies
- Improve: More real-world use case stories and examples
#### ๐งฉ Kinesthetic learners
- Present: Live coding session, copy-paste examples, hands-on demonstrations
- Improve: Step-by-step implementation checklists
#### ๐ง Logical learners
- Present: Clear approach categorization, decision trees for method selection
- Improve: Flowcharts for when to use each approach
#### ๐งโ๐คโ๐ง Social learners
- Present: Live chat interaction, community resource sharing
- Improve: Group coding exercises, command sharing gallery
#### ๐งโโ๏ธ Solitary learners
- Present: Self-contained code examples, individual exploration
- Improve: Self-assessment quizzes on approach selection
#### ๐ฟ Naturalistic learners
- Present: Organic development flow, iterative problem-solving
- Improve: Ecosystem thinking about command relationships
### ๐ Accessibility Assessment
#### Screen reader semantics
- Present: Code structure with proper headings
- Improve: Alt text for code screenshots, ARIA labels for live demo
#### Keyboard navigation
- Present: Command palette designed for keyboard-first interaction
- Improve: Ensure all demo commands are keyboard accessible
#### Contrast and readability
- Present: High contrast code examples
- Improve: Check video streaming contrast levels
#### Text resizing and reflow
- Present: Code examples scale appropriately
- Improve: Ensure video player controls remain accessible when zoomed
#### Media and captions
- Present: Live verbal explanation
- Improve: Auto-generated captions, transcript availability
#### Forms and interactions
- Present: Command palette interactions well-labeled
- Improve: Error state handling in custom commands
### ๐ DEIB Assessment
#### Cultural breadth
- Present: English-language focused but open to global participation
- Improve: Multi-language command examples, internationalization discussion
#### Inclusive language
- Present: Technical terms explained, jargon defined
- Improve: Plain language summaries, avoid assumptions about prior knowledge
#### Neurodiversity support
- Present: Clear structure, consistent pacing
- Improve: Content warnings for rapid code changes, pause points
#### Representation
- Present: Single presenter but encouraging community participation
- Improve: Guest perspectives, diverse use case examples
#### Psychological safety
- Present: Encouraging questions, admitting uncertainty
- Improve: Explicit welcome for all skill levels
### โ
Logical Validity
#### Strong reasoning
- Deductive strength: Clear categorization of three command approaches based on technical constraints
- Inductive strength: Examples build from simple to complex implementations
- Causal reasoning: Links technical limitations to architectural solutions
- Analogical strength: Good comparison between editor vs admin contexts
#### Fallacies
- None identified: Technical explanations are well-grounded in code examples
#### Tone of voice
- Overall tone: Collaborative and exploratory, encouraging experimentation and learning
### ๐ก๏ธ DARVO Analysis
- Deny: Not applicable - technical content
- Attack: Not applicable - technical content
- Reverse victim/offender: Not applicable - technical content
- Emotional cues and rhetoric: Positive, encouraging tone promoting learning and exploration
## ๐ฏ Conclusion
WordPress 6.9's expanded command palette creates significant opportunities for improving developer and user workflows throughout the admin interface. The three main approaches - direct dispatch, React hook mounting, and register_plugin integration - each serve specific use cases and technical requirements.
For developers, start with simple navigation commands using the dispatch method, then progress to React integration as complexity needs grow. The contextual command system provides elegant UX prioritization that should be leveraged thoughtfully.
The broader implications suggest command palette development will become an essential skill for WordPress developers, potentially influencing how we design admin interfaces and user workflows across the entire ecosystem.
## ๐งฑ Refactor Appendix
### ๐ Literature Split Pad
### [H1] Command palette expansion enables universal admin commands
> [!quote] [Creating commands for the Commands Palette](https://www.youtube.com/watch?v=ETqUp0UXH0k) by [[Mario Santos]] via [[YouTube]]. Published 2024-12-19. Accessed 2024-12-19.
> "WordPress 6.9 the command palette is available everywhere"
Significant expansion from editor-only to admin-wide availability.
[view highlight](https://youtu.be/ETqUp0UXH0k?t=323) #wordpress #command-palette ID:rw_cmd_palette_expansion
### [H2] React hooks require environment outside traditional admin
> [!quote] Creating commands for the Commands Palette
> "These hooks can only be executed inside React components"
Core technical challenge for universal command compatibility.
[view highlight](https://youtu.be/ETqUp0UXH0k?t=525) #react #wordpress-architecture ID:rw_hooks_challenge
---
### ๐ Atomic Split Pad (Zettel Candidates)
#### [Z1] Three patterns exist for WordPress command registration
- Simple dispatch, React mounting, register_plugin approaches each serve different contexts
- Pointer to 12:30 timestamp and implementation examples
- Links: [[WordPress-Command-Palette]] [[React-Integration-Patterns]]
#### [Z2] Contextual commands improve user experience through prioritization
- Commands appear first in relevant contexts like site-editor or entity-edit
- Pointer to 58:30 timestamp and context demonstration
- Links: [[User-Experience-Design]] [[WordPress-Admin-Interface]]
---
### โ๏ธ Fleeting Queue
- [F1] Explore command grouping solutions for growing ecosystem โ GitHub issues discussion #fleeting #commands
- [F2] Test
---
## Full Transcript
[04:01] and we are live.<br>[04:05] Let me send a message<br>[04:08] and then we can start with the session.<br>[04:15] In the meantime, please say hi if you<br>[04:17] are there.<br>[04:44] Okay,<br>[04:49] we are connected and the<br>[05:02] I'm sharing this session<br>[05:05] in a slack<br>[05:07] child.<br>[05:25] Okay.<br>[05:29] Yes. So people<br>[05:31] are aware of this.<br>[05:41] And now I'm ready.<br>[05:44] Okay, welcome<br>[05:47] everybody to another session,<br>[05:52] another stream,<br>[05:55] another stream where um<br>[05:59] I usually just work in public about<br>[06:02] stuff and I share what I have learned<br>[06:04] during the the week and yeah, it's like<br>[06:08] an open space so anyone can connect and<br>[06:12] ask questions.<br>[06:14] and yeah maybe just chip in<br>[06:19] how<br>[06:20] other developer is working about<br>[06:22] something.<br>[06:24] So today I want to explore a bit further<br>[06:30] the command palid and the creation of<br>[06:33] commands.<br>[06:34] I've been<br>[06:37] exploring this a little bit in this past<br>[06:41] uh few days.<br>[06:44] And I'm actually in the middle of<br>[06:46] exploring some stuff. So I want to share<br>[06:48] that with you and maybe work on these<br>[06:49] things together and see what we can<br>[06:54] what we can do or if we can solve<br>[06:56] something or if we can create some uh<br>[06:59] new commands. I also<br>[07:03] published this article a few weeks ago<br>[07:12] because I started this exploration. I<br>[07:14] actually did another stream<br>[07:19] at the yeah a few weeks ago in Spanish<br>[07:23] and I struggle with a few things<br>[07:26] so I decided to write about it. The<br>[07:29] thing is that um now in WordPress 6.9<br>[07:36] the command pallet is um it's available<br>[07:40] everywhere. Before<br>[07:43] WordPress 6.9<br>[07:46] the common pallet was only available in<br>[07:49] the block editor in the post editor or<br>[07:53] in the site editor but now it's<br>[07:56] available um everywhere. So that comes<br>[08:01] this brings new challenges. Um<br>[08:05] the main challenge I faced is that when<br>[08:08] you create commands there are some<br>[08:11] helpers to create these commands but a<br>[08:13] lot of these helpers are hook are hooks<br>[08:17] and these hooks can only be executed<br>[08:20] inside React components.<br>[08:22] And the thing is that outside of the<br>[08:25] post editor<br>[08:27] there are no usually uh there's no react<br>[08:30] environment.<br>[08:32] So we if we want to use those hooks and<br>[08:36] those hooks are useful if we want to<br>[08:39] interact with a store or something like<br>[08:41] that. We need to find a way to<br>[08:45] make or<br>[08:47] command to work in<br>[08:52] all the the contexts in all the<br>[08:56] environments. It should work either in a<br>[08:59] page that has a react<br>[09:04] um<br>[09:06] environment and in pages that doesn't<br>[09:08] have that react environment.<br>[09:10] Um so yeah, I did an exploration. I came<br>[09:14] up with a few solution. I would like to<br>[09:15] review them to see if we can improve the<br>[09:18] the approach on each of them.<br>[09:22] and<br>[09:24] okay the chat sorry if I don't answer in<br>[09:28] the chat because the chat is not<br>[09:30] connecting here let me see if I can<br>[09:34] solve this somehow<br>[09:36] and now I can see the chat<br>[09:40] hello<br>[09:46] so yeah if you are there say hi say<br>[09:52] from where you are connecting.<br>[09:57] And yeah, if you have any any questions<br>[09:59] about this um<br>[10:02] this whole thing of creating commands<br>[10:05] for the for the command pallet.<br>[10:11] Okay. So let's start by<br>[10:15] I'm going to show what I have so far of<br>[10:19] the expiration that I'm doing and I'm<br>[10:22] also in the middle of checking a pull<br>[10:24] request that has to do with this<br>[10:26] creation of commands. So maybe we can<br>[10:28] explore that together and then maybe we<br>[10:31] can uh we can go through these different<br>[10:35] examples and<br>[10:38] and just talk about them.<br>[10:41] I think that what I'm going to do is I'm<br>[10:43] going to share. Let me see if I where do<br>[10:48] I have this? I think it's here.<br>[10:54] Yeah, this is the project that I have.<br>[10:58] And this is the article.<br>[11:00] So, yeah, let's start. I think we can<br>[11:03] start here by<br>[11:06] or maybe we can check the the<br>[11:07] documentation a little bit.<br>[11:15] Uh, I have to. Okay, let me see.<br>[11:20] I'm not logged in here.<br>[11:25] Okay, let me<br>[11:29] um<br>[11:35] shouldn't I have Let me see.<br>[11:39] uh because I'm not logged in. Well, that<br>[11:42] can be solved very easily.<br>[11:45] I want to access this uh Twitter because<br>[11:49] I have here some<br>[11:54] resources. Well, actually I have them<br>[11:55] here as well. Yeah, that's what I wanted<br>[11:58] to<br>[12:00] to share with you.<br>[12:04] like these resources. I'm going to share<br>[12:07] them in the<br>[12:10] in the chat. Well, by the way,<br>[12:15] um<br>[12:17] I want to<br>[12:19] mention that I have<br>[12:22] published a new post in the developer<br>[12:25] blog which I think is uh is is really<br>[12:30] interesting because it<br>[12:34] it talks about how to combine like<br>[12:36] different APIs in WordPress to create<br>[12:39] effects or to create any behavior you<br>[12:43] want to to implement. And this is a<br>[12:47] really interesting use case because it<br>[12:49] covers<br>[12:51] both APIs<br>[12:53] that affect the edition experience and<br>[12:57] also the user experience.<br>[13:00] So we are<br>[13:04] we are implementing<br>[13:06] um<br>[13:08] the experience in both sides of the<br>[13:11] equation.<br>[13:13] So the effect is this.<br>[13:17] So we have for example a series of words<br>[13:21] separated by commas and I can select<br>[13:23] that text as a format and this is the<br>[13:26] addition experience. I can just okay I<br>[13:28] want this to be a word switcher effect.<br>[13:31] So each word will be detected will be<br>[13:34] isolated and will be presented in the<br>[13:36] form of this effect. So this is what<br>[13:39] this article is about and this um effect<br>[13:45] is done by leveraging the format API,<br>[13:50] the interactivity<br>[13:53] API, HTML API and also using JavaScript<br>[13:57] modules which we need to register and we<br>[14:00] which we need to build as a module. So<br>[14:03] there are some um<br>[14:06] some things to be taken into account and<br>[14:09] all of that is explained in this<br>[14:11] article. So yeah, I really recommend you<br>[14:14] I'm going to share this in the in the<br>[14:17] chat. Whoops. I'm going to<br>[14:21] share this in the chat.<br>[14:25] And without further ado, we can move on<br>[14:29] with the with the command pallet API.<br>[14:34] So the command pallet ai command pallet<br>[14:37] in case you don't know what I'm talking<br>[14:38] about is uh this when we are in the<br>[14:42] admin and now the in WordPress 6.9 the<br>[14:45] command pallet is available everywhere<br>[14:47] which means that is available here. This<br>[14:50] wasn't possible in WordPress 6.8 eight.<br>[14:54] And now since WordPress 6.9 this is um<br>[15:00] this is enabled and we can move around.<br>[15:04] We can go through we can go to a<br>[15:08] specific posts or specific pages<br>[15:12] or we can<br>[15:14] um go<br>[15:17] directly to a specific uh template.<br>[15:22] And from here maybe we can go to um<br>[15:29] we can go to editor<br>[15:33] appearance editor<br>[15:36] and yeah we can move around and the cool<br>[15:39] thing is that we can also create our own<br>[15:42] um we can create our own commands and<br>[15:46] this is what we are going to explore<br>[15:48] today.<br>[15:50] For example, one way to create a command<br>[15:53] is using this uh use command<br>[15:58] which is a React hook. And this React<br>[16:00] hook needs to be executed inside of our<br>[16:04] React component. And that React<br>[16:05] component needs to be um hydrated<br>[16:09] somehow into the DOM. And we need to<br>[16:11] find a way to to to do that.<br>[16:21] So let's explore this a little bit. Um<br>[16:26] what I want to<br>[16:32] what I want to move here is the studio<br>[16:34] where I have this<br>[16:36] um<br>[16:38] actually<br>[16:40] let's create a new site site um commands<br>[16:46] valid<br>[16:47] exploration<br>[16:53] I'm going to add the site. I'm going to<br>[16:56] make it<br>[16:59] I want to create a um<br>[17:04] like a local domain and we can do this<br>[17:08] here. If I edit site custom domain<br>[17:12] and commands valid expiration, I want to<br>[17:14] enable https.<br>[17:25] And with that<br>[17:27] what I want to do is I want to<br>[17:32] link the project that I have here under<br>[17:34] the folder common p valid exploration.<br>[17:38] So to do that, I'm going to come here.<br>[17:46] Um,<br>[17:48] running.<br>[17:52] I think it's because I created the<br>[17:55] domain. After that, I need to stop it<br>[17:59] and launch it again.<br>[18:03] Start.<br>[18:09] Okay. And now we have the site.<br>[18:14] And if I go to overview to iTerm,<br>[18:22] I'm going to go to uh to the plugins<br>[18:25] folder<br>[18:27] and I'm going to link the<br>[18:31] the project where I have all this<br>[18:33] initial exploration.<br>[18:36] Uh it's called commands uh valid no<br>[18:41] exploration command.<br>[18:44] valid exploration.<br>[18:48] So now that I have this project here, I<br>[18:52] should have it in plugins<br>[18:54] and I should be able to activate it and<br>[18:58] this<br>[19:02] um register this custom commands that I<br>[19:05] have created. So these are commands to<br>[19:07] access directly the the handbooks<br>[19:09] directly from the from the command<br>[19:11] pallet. So for example, if I click here,<br>[19:13] I go directly to the blockator handbook.<br>[19:16] Or if I click here, I go directly to the<br>[19:19] theme handbook.<br>[19:22] And the nice thing is that um I can look<br>[19:26] I can search for the words in the the<br>[19:30] title,<br>[19:32] but also I can add some keywords. For<br>[19:35] example, whenever I search for dogs,<br>[19:38] these results appear. So how have I done<br>[19:41] this? Um<br>[19:47] so this is how this is done. This is I<br>[19:50] think the easiest way to to register um<br>[19:53] a command.<br>[20:06] It seems that is offline.<br>[20:11] I'm not sure if I'm streaming right now<br>[20:13] or not<br>[20:17] because it appears offline OBS. Let me<br>[20:21] quickly check this. If I go to YouTube<br>[20:27] and I go to my channel.<br>[20:37] Yeah, it seems that this is streaming.<br>[20:41] Okay.<br>[20:44] Okay. Yeah. Back again.<br>[20:47] Back again.<br>[20:50] Yeah, this OBS software is is really<br>[20:52] strange. I<br>[20:55] I don't fully understand it to be<br>[20:57] honest. So, every from time to time I<br>[21:00] have like these little surprises that I<br>[21:02] have to I have to deal with. Well,<br>[21:05] anyway,<br>[21:07] um<br>[21:08] how these commands are registered. So,<br>[21:11] we can use the<br>[21:14] dispatch method of WordPress data. Um,<br>[21:21] WordPress data is the data layer of the<br>[21:27] of the<br>[21:30] stores that centralize the the data.<br>[21:37] If we come here,<br>[21:40] expect<br>[21:49] Okay, let me I'm going to close<br>[21:53] all the<br>[22:03] I think is if I come here to inspect and<br>[22:06] I go to redux<br>[22:09] here we can see the stores. So the<br>[22:12] stores are<br>[22:14] available. If we come here to the<br>[22:16] console and we check Dolbyp,<br>[22:21] we can see that there are a lot of<br>[22:24] objects and<br>[22:28] shared under the Dolby VP global object.<br>[22:31] So we can we have access to the API<br>[22:34] fetch uh function but also to the blocks<br>[22:39] object the block editor and all of them<br>[22:42] they have a thing called store<br>[22:49] and this store is the one that we can uh<br>[22:54] pass to<br>[22:56] Dolbyp data<br>[23:01] um<br>[23:03] to dispatch actions or to select data.<br>[23:08] If we come here to Redux, we can see<br>[23:11] here how there are different stores<br>[23:14] available. One of the stores we have is<br>[23:16] called commands. And here we can see we<br>[23:19] should see all the commands that are<br>[23:21] registered.<br>[23:23] And<br>[23:25] we should see here our<br>[23:29] own commands the ones that we have<br>[23:32] registered.<br>[23:34] Let me see if I can find them.<br>[23:39] Um<br>[23:43] what is the name? The name of is command<br>[23:47] API exploration.<br>[23:53] command and here here they are. Command<br>[23:55] API exploration docs block editor and<br>[24:00] whenever this command is called I<br>[24:04] trigger a specific callback which in our<br>[24:07] case is uh just a window open to the<br>[24:10] specific link according to this array of<br>[24:13] objects where I have defined all the uh<br>[24:17] data of the different handbooks.<br>[24:20] So what I do here is I loop over the<br>[24:24] array and for each object I register the<br>[24:27] command. How do I register the command?<br>[24:30] I dispatch an action which is register<br>[24:32] command of the command store.<br>[24:37] So we come here and we do commands.<br>[24:50] Um<br>[24:51] no, if I do if I do DVP data and then<br>[24:57] DVP<br>[24:59] commands um store<br>[25:08] If I do WP data this patch comment<br>[25:14] store, this should<br>[25:17] return<br>[25:19] a set of actions we can trigger to<br>[25:24] alter the data that is in the Redux<br>[25:29] store.<br>[25:31] And one of the actions is register<br>[25:33] command. So we do data dispatch the<br>[25:36] specific store in this case in the<br>[25:38] command store and register command and<br>[25:41] register command. If we check the<br>[25:43] documentation here<br>[25:49] register uh command.<br>[25:54] If we look for register command,<br>[25:59] we have here we have here the commands<br>[26:01] data register.<br>[26:06] Well, this is not really useful. So,<br>[26:08] let's go with the other result.<br>[26:19] Yeah, this is the information we need to<br>[26:20] pass to register a command. name, label,<br>[26:23] icon, call back, context, the context of<br>[26:25] the command and the keywords.<br>[26:32] So this is a way of registering a<br>[26:34] command.<br>[26:38] And um<br>[26:42] this is what I've done here.<br>[26:46] And this is a good way because if we<br>[26:48] don't need any<br>[26:51] thing that is super complex, this is<br>[26:53] good enough.<br>[26:56] But what happens if we need to interact<br>[27:00] with<br>[27:02] um<br>[27:05] other hooks and we want to use the hook<br>[27:10] way of registering a command. For that<br>[27:13] we have the use command hook.<br>[27:17] And<br>[27:21] and if we need that and for example if<br>[27:23] we need a models or um<br>[27:29] other effects that can be triggered uh<br>[27:33] from react. We need to<br>[27:37] find a way of<br>[27:40] um mounting manually a react um<br>[27:47] a react container and so this is<br>[27:51] properly hydrated into the dome.<br>[27:55] This is an example. So let's copy this.<br>[27:58] Let's comment this a little bit.<br>[28:04] For example,<br>[28:06] um we can call this<br>[28:09] latest<br>[28:12] posts.<br>[28:19] Okay. Yes.<br>[28:22] And I'm going to copy this<br>[28:38] Okay.<br>[28:42] And what I can do here is okay this<br>[28:45] latest posts and right now<br>[28:50] I'm going to move this logic to the<br>[28:52] index.<br>[29:02] I'm appending a specific DOM element and<br>[29:05] inside that do element I'm creating a<br>[29:08] root to render a specific<br>[29:10] um<br>[29:13] react component which is the one I'm<br>[29:15] going to import<br>[29:18] from here.<br>[29:22] I also need to<br>[29:26] I'm going to remove this<br>[29:30] and I'm going to export<br>[29:34] default<br>[29:37] function.<br>[29:39] This this is a<br>[29:43] a React component.<br>[29:45] What else? the dump ready. I'm going to<br>[29:48] move it to<br>[29:55] I'm going to move it to and uncreate<br>[29:57] root as well.<br>[30:00] And yeah, we should have<br>[30:04] we should have<br>[30:07] no latest<br>[30:10] post uh command<br>[30:15] post commands. Okay.<br>[30:18] So, how are we doing this?<br>[30:25] This is the<br>[30:28] React component that we are<br>[30:34] we are invoking. We are um triggering<br>[30:38] when the specific command is uh called<br>[30:41] is summoned.<br>[30:45] This react component has uh two states<br>[30:48] is open and set is open. Is open will be<br>[30:51] true or false depending if the specific<br>[30:54] uh model is rendered or not.<br>[31:04] So this um react component<br>[31:10] make use of the use command which is a<br>[31:13] hook available from the WordPress<br>[31:16] commands. And if we look for use<br>[31:18] command,<br>[31:21] we look for use command.<br>[31:26] We can see that<br>[31:30] attach a command to the command pallet<br>[31:32] used for static commands.<br>[31:41] Um<br>[31:43] but we need to<br>[31:48] appear this command<br>[31:51] this commands. Okay. If we look for use<br>[31:54] command, let me look for that in<br>[31:55] Gutenber.<br>[31:59] We look for Gutenber and we look for use<br>[32:02] command<br>[32:06] export hooks. Yeah, we can see that this<br>[32:09] is a hook hook. The hook use command<br>[32:16] and it's a hook. It uses this effect.<br>[32:19] So, we need to to to launch this from um<br>[32:23] from a React component.<br>[32:26] And that's why I'm doing this.<br>[32:29] That's why in order to render this<br>[32:33] React component that internally<br>[32:38] is uh making use of the hook use<br>[32:42] command.<br>[32:44] We are um<br>[32:47] what we are doing is via JavaScript we<br>[32:50] are creating a DOM element<br>[32:54] and<br>[32:56] we are hydrating that uh DOM element<br>[32:59] with<br>[33:01] my custom<br>[33:04] re component which is the one that is<br>[33:07] making use of the hook<br>[33:10] here<br>[33:12] and Here<br>[33:15] I can call all the react components and<br>[33:18] this react component uh latest post<br>[33:21] model is uh the one<br>[33:26] that<br>[33:29] uses other hooks like you select for<br>[33:33] example the idea let's um let's try we<br>[33:37] can go if we reload code.<br>[33:46] We can do um<br>[33:50] show latest posts.<br>[33:54] And here we can see a specific uh model<br>[33:57] window<br>[33:59] where we can go to the specific post<br>[34:09] and we can show uh<br>[34:13] show latest posts<br>[34:18] and we can go and edit the post. for<br>[34:20] example.<br>[34:26] So this is an strategy that I think it<br>[34:29] can work<br>[34:34] because this is a way to ensure that all<br>[34:37] command registered via hooks is um<br>[34:41] properly registered.<br>[34:48] no matter where this is executed.<br>[34:56] And what I'm doing here is okay, I'm<br>[34:58] using the use select which returns the<br>[35:03] post and is loading.<br>[35:09] This is the query I'm doing. I'm<br>[35:16] selecting<br>[35:19] from the core store which I have<br>[35:23] imported here. I'm using the get entity<br>[35:26] records and there is a good post in the<br>[35:30] developer blog about the get entity<br>[35:32] records. We go to<br>[35:39] well we have use entity records and get<br>[35:42] entity records. So I'm going to share<br>[35:44] this<br>[35:47] in the chat<br>[35:53] and we are getting the post and while<br>[35:56] this is loading the cool thing is that<br>[35:58] I'm showing a spinner and if it's not<br>[36:00] loading I'm h iterating over the<br>[36:05] different items uh retrieved which are<br>[36:08] the different the latest posts because I<br>[36:11] am uh um using this query<br>[36:16] post type post in the query and<br>[36:20] and I can close the the model.<br>[36:26] So this is<br>[36:32] any tips just started coding as a<br>[36:33] beginner. What language do you<br>[36:35] recommend? Wow, that's um it's an<br>[36:38] interesting question. Do you are you<br>[36:41] interested in in programming in in<br>[36:43] WordPress or just in in general?<br>[36:51] Okay. So we have here a model<br>[36:56] um component which we can import from<br>[37:00] spinner and then the external link.<br>[37:04] This is the<br>[37:10] Okay. In general,<br>[37:12] um, okay, so UB sounds is asking about a<br>[37:16] specific uh language.<br>[37:19] If you are starting, I would recommend<br>[37:21] to start with a programming language um,<br>[37:25] such as JavaScript or Python. I think<br>[37:28] those are the<br>[37:30] the easiest ones to learn and the ones<br>[37:34] you can do the most. uh from my<br>[37:36] experience both Python and JavaScript<br>[37:39] are pretty popular. There are a lot of<br>[37:42] um projects done in in in<br>[37:46] Python and JavaScript and and there are<br>[37:50] a lot of resources on the web. So yeah,<br>[37:53] that would be my recommendation and from<br>[37:55] there you can uh move and explore other<br>[38:00] languages uh such as uh yeah PHP or or<br>[38:05] any other also depending on what type of<br>[38:07] uh products you want to to create for<br>[38:11] the web for example. Hey Elliot, how you<br>[38:14] doing? Hi.<br>[38:19] We're talking about programming<br>[38:20] languages. It's a<br>[38:23] very open open big topic.<br>[38:30] What career paths do those offer? Um<br>[38:34] well these programming languages<br>[38:38] I think there is a lot of uh work for<br>[38:41] for these programming languages. And<br>[38:49] so for example, if you learn PHP um for<br>[38:54] WordPress related uh projects, I think<br>[38:57] there is a lot of uh<br>[39:01] a lot of jobs in that in that uh<br>[39:04] ecosystem. Um and also if you learn PHP<br>[39:09] and JavaScript which are like the most<br>[39:11] uh<br>[39:15] Yeah.<br>[39:17] Yeah. I agree.<br>[39:19] Actually is saying like I think every<br>[39:21] programming language offers path in<br>[39:23] every domain. Yes. Some are more<br>[39:24] dominant than others. Yeah.<br>[39:28] Yeah. From my perspective, I think that<br>[39:30] the JavaScript and Python are pretty<br>[39:32] popular. So that's like um um<br>[39:40] that's a good direction to start with.<br>[39:42] something. But yeah, from from there um<br>[39:47] it depends on what you're interested in<br>[39:50] like if you interested in developing<br>[39:53] games for example or web pages or or any<br>[39:57] other.<br>[39:59] Okay. So let's uh go back to our command<br>[40:03] and<br>[40:05] just to summarize we have um<br>[40:10] we have reviewed two ways of creating<br>[40:12] commands. The first one is the easiest<br>[40:15] one. Um yeah Elliot is saying choosing a<br>[40:19] single programming language is hard. I<br>[40:21] found that the best way to learn is to<br>[40:23] just build things and experiment with<br>[40:24] different ways of doing them. Yeah.<br>[40:27] Yeah. I agree. I agree.<br>[40:31] Do any of you have any um<br>[40:36] favorite programming language? Something<br>[40:38] you feel comfortable with or something<br>[40:40] that you would recommend? I mean um if<br>[40:43] someone is asking you this question,<br>[40:46] which programming language<br>[40:49] should I learn? Do you have like a a<br>[40:51] recommendation?<br>[40:54] For me it would be um<br>[40:58] it would be JavaScript actually<br>[41:02] that would be my my recommendation<br>[41:06] like to start with something because<br>[41:08] it's a language you can use for both the<br>[41:09] front end and the and the back end and<br>[41:12] it's pretty flexible.<br>[41:18] Taxil says, "I like JS and C++ even<br>[41:22] though I don't code in it." Yeah,<br>[41:31] there was this video the other day. I<br>[41:33] saw Yeah, says JS, HTML, CSS, and JST.<br>[41:38] Yeah, I think that combo is pretty<br>[41:40] especially for the web<br>[41:44] like understanding deeply JavaScript,<br>[41:47] HTML and CSS. It's very powerful. It's<br>[41:50] very powerful because with JS you can<br>[41:53] manage the behavior in the front end but<br>[41:57] also a lot of logic in the back end and<br>[42:00] understanding good markup and and CSS.<br>[42:04] Uh<br>[42:08] so Jubie says from what I observed is<br>[42:11] the most hirable or what do you think<br>[42:18] like a JavaScript Yeah, I would say for<br>[42:22] me I think JavaScript, Python, PHP are<br>[42:27] like good bets, are like good options.<br>[42:30] This is a matter of exploring them, see<br>[42:33] what you like most about them and then<br>[42:36] and continue<br>[42:38] doing them. The good thing is that<br>[42:40] nowadays with AI, you can really I I<br>[42:43] really like this current time we're<br>[42:46] living in because you can really<br>[42:49] you can really explore any language<br>[42:51] without having any idea and just let AI<br>[42:54] to to guide you through that. So you can<br>[42:56] say okay uh let's create something and<br>[43:00] guide me through every step of it and<br>[43:02] you can ask questions and it's like a a<br>[43:04] good way to to learn<br>[43:07] to learn things. Um,<br>[43:10] sometimes I think it's like a the<br>[43:14] feeling I have when I use Google Maps.<br>[43:18] AI is free tutori. Yeah, I agree. I<br>[43:21] agree. For example, when we use Google<br>[43:24] Maps, we go into a place we haven't been<br>[43:27] before and we just move around like if<br>[43:29] we live there because we can um<br>[43:34] we can go in a new town and we can just<br>[43:36] set an appointment at a specific time<br>[43:38] and we can just be like very tight tight<br>[43:43] time like um trusting the time the<br>[43:46] Google Maps is uh saying it's going to<br>[43:49] take and we can move around uh with uh<br>[43:53] going to addresses we<br>[43:57] haven't been there before. So yeah, it's<br>[44:00] like moving around places we are not<br>[44:03] familiar with and we we haven't been<br>[44:06] before. And for me AI<br>[44:09] um I feel it uh in a similar way. I can<br>[44:13] start uh working with um a programming<br>[44:16] language I don't know with a framework I<br>[44:19] don't know and I can just ask questions<br>[44:21] and I can learn as I I do think what do<br>[44:24] we all do before will maps<br>[44:28] I don't know I don't know<br>[44:30] because I I use it even if I know the<br>[44:33] the the<br>[44:36] way<br>[44:43] because sometimes yeah I<br>[44:48] um What other uh platform do you stream?<br>[44:53] I'm streaming in<br>[44:56] Twitch and<br>[45:01] Okay, you are from Twitch. I stream at<br>[45:05] the same time into Twitch and<br>[45:09] YouTube.<br>[45:10] So if we<br>[45:13] if you go to YouTube, I'm sharing here<br>[45:17] the my channel.<br>[45:25] So this is my channel and if you're<br>[45:29] interested in<br>[45:31] WordPress development, I have a lot of<br>[45:35] a lot of videos there from the streams<br>[45:39] that I<br>[45:41] that I do from time to time. I'm also<br>[45:44] pretty active in my blog.<br>[45:47] So I'm sharing that resource as well<br>[45:49] here.<br>[45:52] Um,<br>[45:53] what else?<br>[45:58] I'm also pretty active in GitHub and I<br>[46:04] have in GitHub uh<br>[46:07] a map of all the things I've been<br>[46:11] working on. So, yeah, that's another uh<br>[46:14] good uh reference for what I've been<br>[46:17] doing.<br>[46:19] Okay, let's go back to the commands.<br>[46:23] Two ways we have seen so far. Um,<br>[46:28] cool.<br>[46:30] Um,<br>[46:32] we have<br>[46:35] checked ways to register commands that<br>[46:39] work in all pages that work in both the<br>[46:42] admin dashboard and in the citator and<br>[46:44] in the pulsator.<br>[46:46] First way is this one<br>[46:51] this patch.<br>[46:53] Actually we can do a very<br>[46:59] a very quick<br>[47:01] test<br>[47:05] if we<br>[47:08] look if we go to my GitHub page. This is<br>[47:14] um this is something that I uh generate<br>[47:18] automatically every day. So this is<br>[47:20] really cool. The project is here. This<br>[47:23] is my GitHub because I have like<br>[47:26] different organizations in GitHub and<br>[47:30] this is the one that I use for WordPress<br>[47:32] development. And in this specific<br>[47:35] organization in the landing page of this<br>[47:37] organization, I have this uh list of<br>[47:40] resources that I<br>[47:43] that I like or that I'm working on. And<br>[47:46] for example, what I have here is a link<br>[47:48] to some guests. And<br>[47:53] what I want to show you here is that I<br>[47:56] have<br>[47:58] I have a Giz here<br>[48:02] which is a way to create a new command.<br>[48:05] I'm going to share this here.<br>[48:09] Okay. So the cool thing about this<br>[48:11] command is that we can copy.<br>[48:14] We can go to any<br>[48:17] WordPress installation.<br>[48:22] So if I<br>[48:25] type command K, I launch this command<br>[48:28] palid and if I type which is my name,<br>[48:33] there's no command. But<br>[48:37] if I copy and paste this, I can register<br>[48:40] a command using the same approach we<br>[48:44] have used here. The difference here is<br>[48:46] that we are using a build process. So we<br>[48:49] are importing the different libraries<br>[48:53] and generating a build version. And this<br>[48:55] is the one that we are loading. But here<br>[48:58] we are using directly the<br>[49:04] the packages that are<br>[49:07] um published in WordPress. So in<br>[49:09] WordPress the the data package is<br>[49:13] available as a property of the um WP<br>[49:18] global object. The same with the<br>[49:21] commands and<br>[49:24] a lot of other packages. So what we can<br>[49:26] do is directly<br>[49:29] call the dispatch method of the data<br>[49:32] package. We need to pass a specific<br>[49:35] store. This can be like the block store,<br>[49:37] the editor store. In this case, we're<br>[49:39] interested in the comments store. And um<br>[49:42] this dispatch<br>[49:44] method over a store, it returns a set of<br>[49:48] actions that we can execute. Um<br>[49:54] if we do this we can see that we get a<br>[49:57] lot of uh well a lot of uh a number of<br>[50:00] actions like register command and<br>[50:04] this register command we can use it to<br>[50:07] register a command. And if we uh do<br>[50:11] here, we can see how now we have this uh<br>[50:14] command, this custom command that what<br>[50:17] it does is redirect to to my web page.<br>[50:21] But this is a a pretty um<br>[50:25] good way to<br>[50:29] demonstrate how to register commands.<br>[50:32] Okay, so we have this method. Then we<br>[50:34] have this other method, latest posts.<br>[50:37] I'm thinking about the strategy used<br>[50:40] here. I'm not sure. I think it's fine. I<br>[50:42] don't think there<br>[50:45] I'm thinking about the architecture.<br>[50:48] So what we are doing is we are creating<br>[50:50] um a DOM element.<br>[50:54] So let's what we are doing is we are h<br>[50:58] when the DOM is ready we are creating a<br>[51:02] specific deep we are assigning that deep<br>[51:07] an ID we are appending down that to the<br>[51:11] body and then we are uh rendering or<br>[51:16] react component in that uh DOM element<br>[51:19] that we have created on the fly<br>[51:23] and The react component we are rendering<br>[51:25] is called latest post command which is<br>[51:28] this one and this command uh is a react<br>[51:32] component. So inside the react component<br>[51:34] we can use all the<br>[51:37] the different hooks like for example use<br>[51:39] state use command and this<br>[51:45] state variable we use it to<br>[51:52] to display or not this model window.<br>[51:58] can come here and say.<br>[52:02] So when we click<br>[52:06] recently did posts it displays<br>[52:11] um<br>[52:13] it displays the model window based on<br>[52:15] the value of this is open. But when we<br>[52:19] click here,<br>[52:22] we use set this open to false. The on<br>[52:25] close of that model<br>[52:29] uh this on close<br>[52:33] is the one that we pass to the model.<br>[52:36] And when we close and here we can make<br>[52:39] use of other post other hooks like for<br>[52:43] example um you select to get the list of<br>[52:46] posts which is um dynamically<br>[52:52] retrieved and from there we can<br>[52:56] um we have access to both the data and<br>[52:59] both the<br>[53:02] the is loading. Um<br>[53:06] if we come here we can reload. If we go<br>[53:10] to the network we can see this would be<br>[53:13] a fetch I think.<br>[53:17] We see latest<br>[53:19] posts.<br>[53:27] Look how this is triggering a lot of um<br>[53:33] lot of calls to the rest API. But in our<br>[53:36] case, if we do show latest posts,<br>[53:40] we can see how is triggering this rest<br>[53:44] API request via the<br>[53:48] this code.<br>[53:50] This code is triggering the get records<br>[53:54] is<br>[53:56] fetching the data via a rest API<br>[54:00] request.<br>[54:01] This is the data that is retrieved<br>[54:06] and we are displaying this. So yeah, I<br>[54:09] think is uh<br>[54:12] is fine<br>[54:14] because the use command<br>[54:22] this doesn't<br>[54:26] let me see um con command<br>[54:32] and<br>[54:34] console lock command. Let's see.<br>[54:36] I'm not sure if this returns something,<br>[54:38] but just uh<br>[54:45] no undefined. No, it doesn't return<br>[54:47] anything.<br>[54:49] But we can use it to uh to register a<br>[54:53] command. Okay, this is one option, the<br>[54:57] use command.<br>[55:09] Now, if we only want to register<br>[55:12] commands in the in the block editor,<br>[55:17] we can avoid this thing of um<br>[55:24] creating a DOM element and appending<br>[55:26] that DOM element to<br>[55:28] body and then rendering all React<br>[55:31] component in it because we can leverage<br>[55:36] the existing<br>[55:39] React system already rendered because<br>[55:43] the block editor and the post editor is<br>[55:47] just a big uh react application.<br>[55:51] So what we can do is use register plugin<br>[55:54] and the thing is that the thing is we<br>[55:57] need a way to render a react component.<br>[56:00] If we are in the block editor or in the<br>[56:02] post editor, we can leverage register<br>[56:04] plug-in. If we are not or if we want to<br>[56:07] ensure that this works in any page, we<br>[56:09] cannot h rely on this because for<br>[56:12] example in the in the main admin<br>[56:14] dashboard, this won't work. this won't<br>[56:17] work.<br>[56:21] So if our command is only meant for post<br>[56:24] page 18 experience, we can use the<br>[56:25] register plugin.<br>[56:30] So let's create here um<br>[56:35] copy post content.<br>[56:40] Copy post content.<br>[56:53] So let me see this<br>[56:55] um<br>[57:02] for all<br>[57:07] uh in the admin area<br>[57:15] and this is for all pages in the admin<br>[57:19] area. Um using hooks<br>[57:23] and this is h using<br>[57:28] dispatchers<br>[57:31] using a dispatcher.<br>[57:36] And now we are going to use<br>[57:41] we are going to use four uh pages in the<br>[57:46] block editor<br>[57:51] only in the<br>[57:54] block editor editor<br>[57:59] using um plugin render plugin Register<br>[58:08] plugin.<br>[58:11] Using register plugin and<br>[58:15] copy<br>[58:17] post content to people.<br>[58:29] And what I'm going to do is I'm going to<br>[58:32] import the specific React component and<br>[58:34] I'm going to register it here.<br>[58:37] So copy post content.<br>[58:42] This thing I'm going to do it.<br>[58:46] I'm going to export<br>[58:49] default<br>[58:52] function.<br>[58:56] I'm going to export default default<br>[59:06] default function<br>[59:10] post content and the register plugin<br>[59:15] I'll bring it here.<br>[59:25] So now we have a third way of<br>[59:27] registering commands<br>[59:31] which in this way is<br>[59:38] um we are using the register plugin way.<br>[59:44] Quick question. What's the extended<br>[59:46] proper what's the extended proper use<br>[59:49] case of reducer plug-in? Because if we<br>[59:51] just want to load it in the post editor,<br>[59:55] we can do a screen check in PHP while in<br>[59:57] queue in the JS, right? I'm not inclined<br>[60:00] with the JS at all. If it's not going to<br>[60:02] be used, let me see if I understand<br>[60:04] this. Um,<br>[60:11] if we just want to load it in the post<br>[60:13] editor,<br>[60:18] we can do a screen check in PHP.<br>[60:21] Yeah, I'm not sure how to do that. I I<br>[60:24] it rings a bell, but I'm not sure about<br>[60:26] how this would work and not burden<br>[60:29] client with the JS at all if it's not<br>[60:31] going to be used.<br>[60:36] I guess that there are different ways of<br>[60:38] doing the same. I think that um<br>[60:44] I think that you are right. Um you have<br>[60:48] some example of how to do maybe we can<br>[60:50] try that here. How to do a screen check<br>[60:53] in PHP.<br>[60:57] Um<br>[61:03] I I guess this could be another way and<br>[61:06] another um yeah maybe most more<br>[61:10] effective way or more<br>[61:12] uh performant way of doing that. Not<br>[61:15] loading the JS if we are not in the<br>[61:17] block editor.<br>[61:25] In this way we are just um<br>[61:33] in this way this is also not a bad way<br>[61:36] because register plug-in is only going<br>[61:37] to work. I mean register plug-in is uh<br>[61:40] going to be<br>[61:46] well we are importing the register<br>[61:48] plugin function. Yeah that will be the<br>[61:50] the<br>[61:51] and we yeah and we are importing the the<br>[61:54] JavaScript. Yeah, I know what you mean.<br>[61:56] Yeah, we don't need to load this extra<br>[61:58] JavaScript. That's not going to if<br>[62:01] that's not going to work.<br>[62:05] I believe the register plug-in will be<br>[62:07] useful if there are many plugins that<br>[62:09] are defined in JS and we want to<br>[62:11] selectively add particular commands to a<br>[62:13] specific screens.<br>[62:17] Yeah, I think there's also a specific<br>[62:20] context<br>[62:24] property for commands.<br>[62:31] The context the context of the command<br>[62:40] and it says static and dynamic commands<br>[62:43] can be contextual. This means that in a<br>[62:45] given context, for example, when<br>[62:46] navigating the citator or editing a<br>[62:49] template, some specific commands are<br>[62:52] given more priority and are visible as<br>[62:55] soon as you open the command pallet.<br>[62:57] Also, when typing the command pallet,<br>[62:59] these contextual commands are shown<br>[63:01] above the rest of the commands. Okay, at<br>[63:02] the moment, three contexts have been<br>[63:04] implemented. Site editor, this is the<br>[63:06] context that is set when you're<br>[63:08] navigating the site editor.<br>[63:10] Entity edit is the context that is set<br>[63:13] when you are editing a document template<br>[63:16] template part or<br>[63:18] um or page and block selection edit.<br>[63:22] Yeah, but this h it just prioritizes the<br>[63:26] command. So it doesn't mean that it's<br>[63:29] not going to be executed. Um<br>[63:34] but yeah in a specific screen the<br>[63:37] commands um<br>[63:40] of that context will be<br>[63:43] displayed directly when we uh click<br>[63:46] control K and also um when we look for<br>[63:51] that if there are several results it<br>[63:53] will be the first ones uh to appear<br>[63:58] as the usage of the command pallet<br>[64:00] expands more context will be added.<br>[64:04] Attaching a command or command loader to<br>[64:06] a given context is as simple as adding<br>[64:07] the context property with the right<br>[64:09] context value from the available context<br>[64:10] above to the use command or use command<br>[64:13] loader calls.<br>[64:15] So for example here in our use command<br>[64:22] we can say that this is um<br>[64:30] you're editing a component<br>[64:35] template.<br>[64:37] This is the context that is set when a<br>[64:38] block is selected. Uh okay, let's say we<br>[64:43] want to give this a site editor.<br>[64:46] We can say context<br>[64:53] site editor.<br>[64:56] So this is<br>[65:07] and in the site editor. Okay, if we go<br>[65:11] to the site editor now we have this<br>[65:15] this plugin here. If we go to the site<br>[65:18] editor<br>[65:20] now, if we if we click command K, we can<br>[65:24] see that the the first one that appears<br>[65:26] is the one. And if we um show<br>[65:32] no show,<br>[65:36] we can see that the first one in the<br>[65:40] uh results. But<br>[65:43] if it doesn't match any result, yeah, it<br>[65:45] disappears. But if there are several<br>[65:47] results, it appears the first one. Nice.<br>[65:56] Okay, let's continue with um<br>[66:01] the context pan is cool. Saves a lot of<br>[66:03] travel of else juggling. Yeah,<br>[66:08] there are um I was exploring this<br>[66:11] morning. There are several um issues<br>[66:15] opened in Gutenberg. Let me see if I can<br>[66:17] find some of them.<br>[66:20] Um,<br>[66:23] for example,<br>[66:35] this is one.<br>[66:40] This is the one that I was exploring<br>[66:43] this morning.<br>[66:48] This is another one which I think is in<br>[66:51] the line of what you're saying.<br>[67:04] No, this is another one I was referring<br>[67:07] to. Um<br>[67:16] Yeah, the thing is that as we add more<br>[67:19] custom commands, um there must be some<br>[67:23] ways to<br>[67:25] identify<br>[67:28] like to group them. So this is one<br>[67:30] solution that was proposed like to add<br>[67:34] the like a category or a group or the<br>[67:36] plugin from where this is registered.<br>[67:40] That would be really cool.<br>[67:43] and<br>[67:50] by adding an action<br>[67:53] and the context for each.<br>[67:59] And what else do we have?<br>[68:11] consider more context than<br>[68:21] there was<br>[68:24] yeah this<br>[68:26] issue<br>[68:28] I'm sharing this in the in the chat<br>[68:35] and there was Another one with a lot of<br>[68:38] Let me see if I can find it.<br>[68:44] Ah, this one.<br>[68:46] Command pallet overview. This one.<br>[68:55] Oops.<br>[69:00] Yeah, these are like the different This<br>[69:02] is the one I was I wanted to to share.<br>[69:05] This is like the all the ideas and and<br>[69:08] some of them have been already<br>[69:10] implemented<br>[69:12] but some of the ideas to um for the<br>[69:15] command pallet and some of them they<br>[69:17] have to do with the accessibility<br>[69:20] um yeah for example this one allow<br>[69:23] hooking into command pallet commands and<br>[69:25] command loaders<br>[69:27] and<br>[69:32] and how to group Um<br>[69:37] I would really like something like um<br>[69:41] I wanted to explore that.<br>[69:46] Um,<br>[69:48] so my expiration could be<br>[69:55] um<br>[69:59] having a way to<br>[70:02] well actually my my explanation would be<br>[70:05] if I<br>[70:07] register commands like this that I have<br>[70:10] a way to see a description of the<br>[70:14] command maybe in the form of a tool tip.<br>[70:17] For me, it would be great if<br>[70:20] I<br>[70:23] keep the mouse in a command for maybe<br>[70:28] more than 3 seconds or 5 seconds. I get<br>[70:31] a tool tip here<br>[70:33] explaining<br>[70:36] in detail what the command is uh going<br>[70:38] to do. But in order to do that I need I<br>[70:41] think we need to um this is not<br>[70:44] something that we can do from a plug-in.<br>[70:46] This is something that we need to<br>[70:49] change the main engine of registering<br>[70:52] commands.<br>[70:55] H but this could be this could be a nice<br>[70:58] a nice addition.<br>[71:01] I'd like to explore that.<br>[71:05] Okay, let's continue. um register<br>[71:08] commands only in the block editor. So in<br>[71:11] our exploration we are using the<br>[71:14] register plugin because we know the<br>[71:15] register plug-in is only going to be<br>[71:18] executed in the<br>[71:22] in the post um<br>[71:26] in the post editor. Also here we are<br>[71:29] doing um<br>[71:36] we are doing some um<br>[71:39] some filters<br>[71:43] but yeah first let's<br>[71:45] let's see if this is registered<br>[71:47] properly.<br>[71:50] We can go<br>[71:53] here<br>[71:55] and we can do<br>[71:59] copy post content to the clipboard. And<br>[72:02] now if we come here we have the the<br>[72:06] content nice.<br>[72:11] So how we can do that? So we have um<br>[72:16] used a hook but in this case we don't<br>[72:19] need to emulate a react um because it<br>[72:23] doesn't make in this case it doesn't<br>[72:25] make sense that we copy the content from<br>[72:28] the admin dashboard. This command only<br>[72:31] makes sense here and what we can do is<br>[72:34] add a context like we did with the other<br>[72:37] thing. Maybe we can also do here context<br>[72:40] edit post because in this case it makes<br>[72:42] a lot of sense. So maybe reload<br>[72:49] and we have commands to go to the to the<br>[72:54] code<br>[72:55] open code editor.<br>[72:58] And here we have a command now to copy<br>[73:02] the content to the clipboard.<br>[73:09] What else? Uh<br>[73:11] now that this is is correct post let me<br>[73:14] check the documentation again.<br>[73:20] Let me check the documentation.<br>[73:23] No is entity edit<br>[73:28] context entity edit.<br>[73:32] Now, in theory, if we<br>[73:40] No.<br>[73:57] If I click<br>[74:01] control K or command Kh<br>[74:15] this is uh<br>[74:18] the context that is said when you are<br>[74:20] editing. Okay. So template template part<br>[74:22] or page but there is no entity edit for<br>[74:24] a post. That's interesting.<br>[74:28] That's interesting.<br>[74:31] So let's try this with a page.<br>[74:36] If we go to a page<br>[74:43] and we edit a page like for example this<br>[74:46] one.<br>[74:49] Um,<br>[74:59] so it's probably registered, but it's<br>[75:01] not really<br>[75:04] the context here is not really working.<br>[75:10] And if we go to a template<br>[75:22] And here, so it's not really a page.<br>[75:26] It's only templates.<br>[75:29] It's only a template because here is<br>[75:32] indeed<br>[75:37] being displayed as um<br>[75:41] so the context is working because it's<br>[75:42] being displayed as the default or the<br>[75:44] most important command for this context.<br>[75:49] But if we go to page or post is not<br>[75:51] doing that.<br>[75:57] So yeah, that's good to know. and block<br>[75:59] selection edit. This is the context that<br>[76:01] is set when a block is selected.<br>[76:08] Are there more contexts? Okay, let's<br>[76:10] check that because maybe maybe this is<br>[76:12] not updated.<br>[76:15] If we come here to Gutenberg block<br>[76:17] selection edit<br>[76:20] this readme<br>[76:22] just set command context.<br>[76:28] So yeah, right now there are only this<br>[76:29] one. Site editor, entity edit,<br>[76:36] a canvas edit.<br>[76:42] Um I'm going to ask<br>[76:50] um can I ask copilot about this?<br>[77:01] Um,<br>[77:05] in which um is<br>[77:08] will this be uh triggered in when<br>[77:13] editing a post<br>[77:16] or page?<br>[77:38] Okay, we need to investigate further.<br>[77:41] It's a rabbit hole. So, let's uh let's<br>[77:45] avoid it.<br>[77:48] Okay. So this is the the third case. We<br>[77:52] are<br>[77:53] we are<br>[77:55] registering a<br>[77:58] command only for the block editor which<br>[78:02] can be either the<br>[78:05] post editor or the site editor.<br>[78:18] And we are also leveraging the notice<br>[78:25] store. Okay. To start closing things.<br>[78:31] So here if I do<br>[78:34] copy<br>[78:37] post content copied to the clipboard.<br>[78:45] So it's very it's very simple. We can we<br>[78:48] are leveraging this um<br>[78:51] native uh methods of the the browser<br>[78:54] navigator clipboard<br>[78:56] write text content and the content we<br>[78:59] are getting it for from a selection to a<br>[79:04] specific uh store which is core editor.<br>[79:07] But maybe we can also say here um import<br>[79:12] store as editor store and maybe we can<br>[79:16] do also this here. So when we reload and<br>[79:21] we say<br>[79:23] copy post uh from clipboard<br>[79:28] we have this here. Nice. Nice.<br>[79:37] Okay, this is a third case.<br>[79:47] So this um<br>[79:51] command is registered for all the<br>[79:57] places where register plug-in works.<br>[80:00] That can be site editor, post editor,<br>[80:04] page editor, whatever. But what if we<br>[80:07] want to be more specific and we want to<br>[80:13] maybe<br>[80:16] um<br>[80:19] register the command or or make the<br>[80:22] command available only if we are in the<br>[80:25] the post editor for example. And for<br>[80:28] that we have this example here which we<br>[80:32] are to comment right now.<br>[80:43] This is block usage model.<br>[80:51] Block usage<br>[80:59] And what I'm going to do is<br>[81:02] export the full function.<br>[81:15] We import the React component and we<br>[81:18] register the plug-in<br>[81:23] only in the block editor. This won't<br>[81:26] work in the site editor. So how are we<br>[81:28] doing this?<br>[81:33] So the React component we are rendering<br>[81:37] is this one and the strategy is similar.<br>[81:41] We have a model window which we are<br>[81:44] controlling<br>[81:46] with<br>[82:08] this open true. And we do the same. We<br>[82:11] just um trigger this block usage model<br>[82:14] or not depending on the value of the is<br>[82:17] open.<br>[82:19] And we close it with the set is open<br>[82:22] false. Okay. And block usage model is<br>[82:25] this one that receives the on close.<br>[82:30] We get the<br>[82:33] the blocks<br>[82:36] of the current uh document.<br>[82:41] And we what what we want to do is to<br>[82:45] count the use of blocks in the current<br>[82:49] uh document. So for that we have this<br>[82:52] logic that goes through each block<br>[82:57] and just counts the<br>[83:05] the times each blocks used across the<br>[83:08] document. And then we<br>[83:10] um<br>[83:12] return the model<br>[83:17] and they use<br>[83:29] and the use block usage<br>[83:32] command.<br>[83:53] Show block usage.<br>[83:57] Ah, okay. And this is a command loader<br>[84:00] and they use common loader<br>[84:04] and let me see use command loader.<br>[84:10] Use command loader.<br>[84:20] and use command loader<br>[84:30] and<br>[84:32] this command<br>[84:36] attach a command loader to the command<br>[84:38] pallet used for dynamic uh commands.<br>[84:47] So maybe in this case<br>[84:56] we can do<br>[85:06] I know in this case we're using a a<br>[85:08] model<br>[85:09] and the block usage.<br>[85:13] Okay, so use block usage command. This<br>[85:16] is the the hook<br>[85:18] that register the commands.<br>[85:42] So we register the command.<br>[86:00] Well, this is I don't think this is<br>[86:02] really well structured.<br>[86:04] I need to improve this.<br>[86:07] Okay, let's analyze this.<br>[86:12] We do a selection using the use select<br>[86:16] hook and we pass the select um method<br>[86:20] and we get different information on<br>[86:22] different stores like the post type of<br>[86:24] the post type, the post ID from editor<br>[86:28] store.<br>[86:31] um<br>[86:33] the post type object<br>[86:36] from cor store and we return if we are<br>[86:39] in the post editor<br>[86:46] or not. The viewable. This is a property<br>[86:48] that is interesting<br>[86:51] because yeah, the viewable property in<br>[86:55] the snippet above code determines<br>[86:57] whether the current post type has a<br>[87:00] public facing edit screen in the<br>[87:02] WordPress admin interface.<br>[87:05] Yeah, because there are several post<br>[87:06] types that doesn't have um<br>[87:10] for example global styles I think is a<br>[87:12] is a post type.<br>[87:15] Um<br>[87:18] I think I have a guest somewhere<br>[87:22] to see um<br>[87:28] the different post types.<br>[87:37] Custom blocks registered.<br>[87:39] Get all items. All post types.<br>[87:50] some block registers.<br>[87:52] No, I don't have here.<br>[87:55] Um,<br>[87:57] but yeah, there are different post<br>[87:58] types.<br>[88:05] But for example, post types that are<br>[88:08] viewable<br>[88:14] Exactly. Yeah.<br>[88:19] Yeah. Yeah. No, it's um Yeah. Says it<br>[88:24] shows whether it has an editor screen<br>[88:26] exactly and not whether we are currently<br>[88:28] the in the editor screen exactly. So um<br>[88:38] we can select the current uh post type,<br>[88:41] the post ID<br>[88:44] and<br>[88:46] but the post type can not be something<br>[88:49] that can be viewable.<br>[88:52] Um<br>[88:54] so with this we are in theory we are<br>[88:58] restricting the access to just uh<br>[89:02] editing a post or editing a page. This<br>[89:05] good<br>[89:07] exclude um<br>[89:15] a template or template part<br>[89:18] viewable<br>[89:20] like whatever we are editing it can be<br>[89:22] viewable directly in the front end<br>[89:24] that's that's how I understand it<br>[89:26] which can be only our posts or pages but<br>[89:30] for example if we edit our template or<br>[89:32] our template part that cannot be<br>[89:35] directly viewed. This is used as an<br>[89:37] internal<br>[89:39] um<br>[89:41] internal piece for generating the final<br>[89:44] render of the page.<br>[89:46] Okay.<br>[89:51] Um<br>[89:54] select from cross store if the user can<br>[89:56] update. Okay. If the user can edit posts<br>[90:00] and the we are in either a post or a<br>[90:04] page,<br>[90:06] we register the command<br>[90:15] commands push.<br>[90:21] Okay, this is a bit uh different because<br>[90:24] command loader<br>[90:26] receives an array of commands even when<br>[90:30] we are here only just adding one command<br>[90:35] commands push.<br>[90:37] Um<br>[90:42] and what we are doing here is open model<br>[90:51] Uh yeah,<br>[90:56] this works but I don't really like the<br>[90:58] how this is structured because there are<br>[91:00] some dependencies here depends on this<br>[91:02] and this is set to null.<br>[91:08] Um,<br>[91:11] I need to think of a better way doing<br>[91:14] this. How can we improve this?<br>[91:20] This is the hook that is<br>[91:24] being called here.<br>[91:32] And the callback<br>[91:41] And the call back.<br>[91:48] The callback needs to<br>[91:53] needs to execute something. Um<br>[92:01] but we are here in a we are in a react<br>[92:05] environment. So<br>[92:10] maybe<br>[92:12] we can um<br>[92:21] is there a way to to render a React<br>[92:24] component?<br>[92:26] Yeah, we don't really. So this is a<br>[92:29] hook.<br>[92:33] Okay, let's ask um cloud code about<br>[92:36] this. Let's see if we can if we can<br>[92:39] improve this code. Okay.<br>[92:44] Um<br>[92:50] okay,<br>[92:52] I'm going to be honest with you, CL. Um<br>[92:54] I don't like the way this code is<br>[92:59] structured.<br>[93:03] Because um<br>[93:09] because block<br>[93:13] is a comment. Um<br>[93:16] sets<br>[93:18] the value<br>[93:21] of open model<br>[93:26] which is<br>[93:27] initialized.<br>[93:29] initialized<br>[93:32] outside of the function<br>[93:36] and<br>[93:46] I'm going to try a new toy that is<br>[93:49] called monologue.<br>[93:54] Okay. Monologue<br>[93:56] is the system<br>[94:01] we can use two. Let me see.<br>[94:09] Okay.<br>[94:11] I don't like the way this code is<br>[94:14] structured because for example the block<br>[94:17] usage command function<br>[94:21] sets the open model<br>[94:24] function that is initialized<br>[94:27] outside of the function<br>[94:31] and also is used inside of the callback<br>[94:38] used in the object<br>[94:43] added to the command array. So is there<br>[94:46] any way we can<br>[94:51] make<br>[94:54] this better.<br>[94:59] Okay, let's see if um<br>[95:03] which ideas.<br>[95:13] Yeah.<br>[95:19] Uh, use context using React context.<br>[95:40] Okay.<br>[95:51] Um, use context.<br>[96:08] Uh, okay.<br>[96:12] So, use context<br>[96:19] Block usage model.<br>[96:31] Open model.<br>[96:45] Okay. Block usage context uh provider<br>[96:50] value set is this open true.<br>[97:12] Okay. use. Well, first let's see if this<br>[97:14] works.<br>[97:20] Let's see if this works.<br>[97:36] So here it's fine that it's not um<br>[97:40] available. But if we go to a page, it<br>[97:43] should be there.<br>[98:01] Um, or maybe say only in the post. Let<br>[98:04] me see.<br>[98:18] Show block usage.<br>[98:29] Yeah. No, this is not working.<br>[98:32] Open model is not a function.<br>[98:46] Isn't there a way to go back?<br>[99:03] So if we go we come here<br>[99:10] show blog usage<br>[99:15] and if we go to a page<br>[99:23] we can show block usage<br>[99:31] only in the Post<br>[99:41] only.<br>[99:43] Okay, this is this part. Can user edit<br>[99:46] post<br>[100:04] is post editor.<br>[100:14] Okay, let me see if I console log.<br>[100:25] Console log.<br>[100:55] post type page.<br>[101:13] Post type view is true.<br>[101:44] If I do console log disposiator and can<br>[101:48] use edit post,<br>[102:01] can you That edit post here is<br>[102:03] undefined.<br>[102:13] Uh I can just update.<br>[102:21] So the first one is true but it's<br>[102:23] because of the second one. So in the<br>[102:25] page<br>[102:29] okay it's because of the second one but<br>[102:31] if we come here<br>[102:42] okay<br>[102:49] can youer update<br>[102:53] post.<br>[102:58] Um,<br>[103:08] I don't really understand this. Can you<br>[103:12] say edit post?<br>[103:17] Why this is only triggered in the<br>[103:20] post editor as true?<br>[103:25] So this is clear. This is that we are in<br>[103:28] a post type that has in a post type.<br>[103:39] We are in a post type that has a<br>[103:44] um<br>[103:46] an screen. Yeah. viewable,<br>[103:49] but<br>[103:52] the post ID,<br>[104:01] let me see. Um,<br>[104:12] okay. And why this return<br>[104:18] Okay. Why can user edit post return true<br>[104:23] only when we are editing a post in the<br>[104:27] post editor<br>[104:30] because it seems that we are checking if<br>[104:34] the user can update the<br>[104:37] post<br>[104:39] but that's also the case for a page. I<br>[104:44] mean the user can also edit a page.<br>[104:47] So yeah, can you explain me why can user<br>[104:50] edit post returns true only<br>[104:56] when we are in the post editor? We are<br>[104:59] editing a post.<br>[105:09] I don't know if clo<br>[105:17] okay. This specifically checks if the<br>[105:19] user can update posts the post type not<br>[105:22] pages. Okay. That's why it returns true<br>[105:25] only when editing a post. The issue is<br>[105:27] that can user<br>[105:30] it's hard to check the post post when<br>[105:32] you are editing a page<br>[105:39] when you editing.<br>[105:55] Okay. Yeah. Uh I don't understand very<br>[105:59] well the logic behind this. Uh can user<br>[106:03] Let me see if Let's dive in a little bit<br>[106:07] more. If we go to the<br>[106:11] we go well actually we can come here and<br>[106:14] say locator handbook<br>[106:18] and we can look for can user<br>[106:22] which is incore data.<br>[106:33] returns whether the current user can<br>[106:35] perform the given action on the given<br>[106:37] red resource. Calling this may trigger<br>[106:38] an options request of recip.<br>[107:12] Okay. Okay. I need to think more about<br>[107:15] this. The thing is that with this filter<br>[107:18] we limit only the<br>[107:21] addition in the post editor<br>[107:26] and um only in that case we are<br>[107:29] registering this because this is the<br>[107:32] hook that returns this object.<br>[107:36] of commands and it's loading false.<br>[107:40] So just common loader is<br>[107:45] and with that command register<br>[107:54] we uh block usage model.<br>[108:11] We trigger this<br>[108:15] and um<br>[108:23] we trigger this. Um,<br>[108:28] okay. I need to think more about this<br>[108:30] example to see if uh I want to clarify<br>[108:34] two things. I want to clarify this.<br>[108:37] I'll think more about this and I also<br>[108:40] want to clarify<br>[108:42] how this hook<br>[108:45] is interacting with this model window<br>[108:48] because right now it's not super clear<br>[108:50] to me. Okay,<br>[108:52] perfect. I think we can<br>[108:56] uh finish the session.<br>[109:00] Hope it's been helpful.<br>[109:04] And yeah, I think this is the last<br>[109:06] session of the year because I'm going on<br>[109:08] holidays.<br>[109:10] So<br>[109:14] yeah, let me give you a reminder of<br>[109:19] my YouTube channel.<br>[109:23] because<br>[109:25] I have done a lot of streams this year.<br>[109:30] There you have all the streams that I<br>[109:32] have done.<br>[109:35] And also if you go to<br>[109:39] my streams<br>[109:43] repository<br>[109:45] there you can find all the details<br>[109:50] all the details of the<br>[109:54] streams that I have done during this<br>[109:55] year that you can find the resources<br>[109:57] that we've been using the<br>[110:02] the projects<br>[110:04] the different diagrams and all of that.<br>[110:09] So yeah, we can call it a year. Um hope<br>[110:12] you have a great holiday that you take<br>[110:15] rest and<br>[110:19] and yeah uh see you next year. Let me<br>[110:23] know via Twitter or you can also<br>[110:28] leave your ideas here in discussions. I<br>[110:30] have a conversation open for ideas for<br>[110:33] streams.<br>[110:34] So, leave here your ideas for the<br>[110:37] streams in case you would like me to<br>[110:41] to cover some specific topic. Okay,<br>[110:44] guys. Hope you're doing fine and yeah,<br>[110:46] see you see you all next year. Bye.
## Highlights
- commands. I've been exploring this a little bit in this past uh few days. And I'm actually in the middle of exploring some stuff. So I want to share that with you and maybe work on these things together and see what we can what we can do or if we can solve something or if we can create some uh new commands. I also ([View Highlight](https://read.readwise.io/read/01kcyk0bzbswy06mdk1f98xk1k))
- Tags: ๐ป ai highlighted
- have like these little surprises that I have to I have to deal with. Well, anyway, um how these commands are registered. So, we can use the dispatch method of WordPress data. Um, WordPress data is the data layer of the of the ([View Highlight](https://read.readwise.io/read/01kcyk0c12mscx17dgdreat898))
- Tags: ๐ป ai highlighted
- So this is a way of registering a command. And um this is what I've done here. And this is a good way because if we don't need any thing that is super complex, this is good enough. But what happens if we need to interact ([View Highlight](https://read.readwise.io/read/01kcyk0c24hytkjm9p45y45t63))
- Tags: ๐ป ai highlighted
- with um other hooks and we want to use the hook way of registering a command. For that we have the use command hook. And and if we need that and for example if we need a models or um other effects that can be triggered uh ([View Highlight](https://read.readwise.io/read/01kcyk0c3a0pcdjwwstwsfrnzc))
- Tags: ๐ป ai highlighted
- And yeah, we should have we should have no latest post uh command post commands. Okay. So, how are we doing this? This is the React component that we are ([View Highlight](https://read.readwise.io/read/01kcyk0c4e6hsy9r5xx5egrbk1))
- Tags: ๐ป ai highlighted
- actions like register command and this register command we can use it to register a command. And if we uh do here, we can see how now we have this uh command, this custom command that what it does is redirect to to my web page. But this is a a pretty um good way to demonstrate how to register commands. ([View Highlight](https://read.readwise.io/read/01kcyk0c8sxydw2mf8n0wcy8t3))
- Tags: ๐ป ai highlighted
- If we are in the block editor or in the post editor, we can leverage register plug-in. If we are not or if we want to ensure that this works in any page, we cannot h rely on this because for example in the in the main admin dashboard, this won't work. this won't work. So if our command is only meant for post page 18 experience, we can use the register plugin. So let's create here um ([View Highlight](https://read.readwise.io/read/01kcyk0cbjyfm5t3kd5kxms7ak))
- Tags: ๐ป ai highlighted
- a tool tip here explaining in detail what the command is uh going to do. But in order to do that I need I think we need to um this is not something that we can do from a plug-in. This is something that we need to change the main engine of registering commands. H but this could be this could be a nice a nice addition. ([View Highlight](https://read.readwise.io/read/01kcyk0cjh1cgp0npwk0mf9w0j))
- Tags: ๐ป ai highlighted
- I'd like to explore that. Okay, let's continue. um register commands only in the block editor. So in our exploration we are using the register plugin because we know the register plug-in is only going to be executed in the in the post um in the post editor. Also here we are doing um ([View Highlight](https://read.readwise.io/read/01kcyk0cpb1mn5heay2fjywcbx))
- Tags: ๐ป ai highlighted
- That can be site editor, post editor, page editor, whatever. But what if we want to be more specific and we want to maybe um register the command or or make the command available only if we are in the the post editor for example. And for that we have this example here which we ([View Highlight](https://read.readwise.io/read/01kcyk0cstb47n27r37a4n81cn))
- Tags: ๐ป ai highlighted