PluginProbe ʕ •ᴥ•ʔ
Nested Pages / trunk
Nested Pages vtrunk
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 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.3.0 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.2 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.3.1 1.6.3.2 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.6 1.6.7 1.6.8 1.7.0 1.7.1 2.0.1 2.0.2 2.0.3 2.0.4 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7
wp-nested-pages / app / Form / Events.php
wp-nested-pages / app / Form Last commit date
Listeners 3 years ago Validation 6 years ago Events.php 4 years ago
Events.php
87 lines
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_nptrashWithChildren',
51 'wp_ajax_nppostSearch',
52 'wp_ajax_npWpmlTranslations',
53 'wp_ajax_npresetSettings',
54 'wp_ajax_npresetUserPreferences',
55 'wp_ajax_npresetAdminMenuSettings',
56 'wp_ajax_nptoggleStatusDisplay'
57 ];
58 $this->setHandlers();
59 }
60
61 /**
62 * Set the Handlers Object
63 */
64 public function setHandlers()
65 {
66 foreach($this->actions as $key => $action){
67 $class = str_replace('admin_post_np', '', $action); // Non-AJAX forms
68 $class = ucfirst(str_replace('wp_ajax_np', '', $class)); // AJAX forms
69 $this->handlers[$key] = new \stdClass();
70 $this->handlers[$key]->action = $action;
71 $this->handlers[$key]->class = 'NestedPages\Form\Listeners\\' . $class;
72 }
73 $this->build();
74 }
75
76 /**
77 * Register the WP Actions
78 */
79 public function build()
80 {
81 foreach($this->handlers as $handler){
82 add_action($handler->action, function() use ($handler) {
83 new $handler->class;
84 });
85 }
86 }
87 }