[wp-trac] [WordPress Trac] #38923: Introduce `WP_Action_Handler` to clean up admin action mess

WordPress Trac noreply at wordpress.org
Thu Nov 24 01:34:07 UTC 2016


#38923: Introduce `WP_Action_Handler` to clean up admin action mess
-----------------------------------+------------------------------
 Reporter:  flixos90               |       Owner:
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  Awaiting Review
Component:  Administration         |     Version:
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+------------------------------
Changes (by flixos90):

 * keywords:  needs-patch => has-patch 2nd-opinion


Comment:

 [attachment:38923.diff] shows what I have in mind. The core of this patch
 are the new files `wp-admin/includes/class-wp-action-handler.php` and `wp-
 admin/includes/action-handler.php`.

 To test the behavior of the new class and to build it in a way that makes
 sense, I also created implementations for two screens, `user-new.php` and
 `post.php`. They both have their own action handler classes, so the code
 two handle their actions has been moved into these classes and the screen
 files are much shorter now as a result.
 Functionality-wise there have not been any changes in the patch,
 everything should work exactly as before.

 While the action handler class was made specifically for use-cases in the
 way that `user-new.php` works, it also brings significant improvements in
 terms of testing and extendability to `post.php` although that file works
 completely different (no messages, basically the entire file is an action
 clause). The functionality for the `edit` action was left in the main file
 since this is not really just an action, but rather displays the entire
 regular admin screen.

 I could probably describe a lot more here, but looking at the code will
 likely give the best overview anyway. If there are any questions about the
 approach, please ask. Also feel free to tear it apart - this patch should
 of course be the opener for a discussion.

 Regardless of how we will scaffold such a class, I think this will
 definitely be a valuable improvement.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38923#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list