PluginProbe
Nested Pages / 3.0.4
Nested Pages v3.0.4
3.3.1 3.2.15 3.2.14 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 All 106 releases
wp-nested-pages / app / Form / Events.php
Events.php
83 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace NestedPages\Form;
3
4 /**
5 * Registers the WP Actions/Handlers
6 */
7 class Events
8 {
9 /**
10 * Actions
11 * @var array
12 */
13 private $actions;
14
15 /**
16 * Handler Class
17 * @var stdClass obj
18 */
19 private $handlers;
20
21 public function __construct()
22 {
23 $this->registerEvents();
24 }
25
26 /**
27 * Set the Form Actions
28 */
29 public function registerEvents()
30 {
31 $this->actions = [
32 'wp_ajax_npsort',
33 'wp_ajax_npquickEdit',
34 'wp_ajax_npsyncMenu',
35 'wp_ajax_npnestToggle',
36 'wp_ajax_npquickEditLink',
37 'wp_ajax_npgetTaxonomies',
38 'wp_ajax_npnewChild',
39 'wp_ajax_npnewBeforeAfter',
40 'admin_post_npListingSort',
41 'wp_ajax_npEmptyTrash',
42 'admin_post_npSearch',
43 'wp_ajax_npclonePost',
44 'wp_ajax_npmenuSearch',
45 'wp_ajax_npnewMenuItem',
46 'admin_post_npCategoryFilter',
47 'admin_post_npBulkActions',
48 'wp_ajax_npmanualMenuSync',
49 'admin_post_npBulkEdit',
50 'wp_ajax_nppostSearch',
51 'wp_ajax_npWpmlTranslations',
52 'wp_ajax_npresetSettings'
53 ];
54 $this->setHandlers();
55 }
56
57 /**
58 * Set the Handlers Object
59 */
60 public function setHandlers()
61 {
62 foreach($this->actions as $key => $action){
63 $class = str_replace('admin_post_np', '', $action); // Non-AJAX forms
64 $class = ucfirst(str_replace('wp_ajax_np', '', $class)); // AJAX forms
65 $this->handlers[$key] = new \stdClass();
66 $this->handlers[$key]->action = $action;
67 $this->handlers[$key]->class = 'NestedPages\Form\Listeners\\' . $class;
68 }
69 $this->build();
70 }
71
72 /**
73 * Register the WP Actions
74 */
75 public function build()
76 {
77 foreach($this->handlers as $handler){
78 add_action($handler->action, function() use ($handler) {
79 new $handler->class;
80 });
81 }
82 }
83 }