Changes between Initial Version and Version 1 of Ticket #61710, comment 5
- Timestamp:
- 06/15/2025 03:45:39 AM (17 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #61710, comment 5
initial v1 1 Thank you for the review and feedback !1 Thank you for the review and feedback @johnbillion 2 2 3 3 I get the concern about the `wp_ajax_all_{action}` hook possibly being confusing, especially since it doesn’t explicitly mention `nopriv` like the existing ones do. However, I’d also like to share why I still believe this could be a helpful addition to the core: 4 4 5 - **Reduced Boilerplate:** Requiring developers to register the same callback twice—once for `wp_ajax_{ $action}` and once for `wp_ajax_nopriv_{$action}` adds unnecessary duplication, especially in projects handling many shared AJAX endpoints.5 - **Reduced Boilerplate:** Requiring developers to register the same callback twice—once for `wp_ajax_{action}` and once for `wp_ajax_nopriv_{action}` adds unnecessary duplication, especially in projects handling many shared AJAX endpoints. 6 6 7 - **Cleaner Code, Fewer Mistakes:** Combining both into a single `wp_ajax_all_{ $action}` hook can help reduce errors (e.g., forgetting to register both hooks or misnaming one), improving maintainability and clarity.7 - **Cleaner Code, Fewer Mistakes:** Combining both into a single `wp_ajax_all_{action}` hook can help reduce errors (e.g., forgetting to register both hooks or misnaming one), improving maintainability and clarity. 8 8 9 9 - **Potential Performance Benefit:** While minor, consolidating the hook registration can reduce the number of callbacks processed during AJAX initialization. For sites with many AJAX actions, this small improvement could contribute to better performance—especially in high-traffic or API-heavy environments.