PluginProbe ʕ •ᴥ•ʔ
Nested Pages / 1.3.4
Nested Pages v1.3.4
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 / FormActionFactory.php
wp-nested-pages / app / Form Last commit date
Handlers 11 years ago Validation 11 years ago FormActionFactory.php 11 years ago
FormActionFactory.php
74 lines
1 <?php namespace NestedPages\Form;
2
3 /**
4 * Registers the WP Actions/Handlers
5 */
6 class FormActionFactory {
7
8 /**
9 * Actions
10 * @var array
11 */
12 private $actions;
13
14 /**
15 * Handler Class
16 * @var stdClass obj
17 */
18 private $handlers;
19
20
21 public function __construct()
22 {
23 $this->setActions();
24 }
25
26 /**
27 * Set the Form Actions
28 */
29 public function setActions()
30 {
31 $this->actions = array(
32 'wp_ajax_npsort',
33 'wp_ajax_npquickEdit',
34 'wp_ajax_npsyncMenu',
35 'wp_ajax_npnestToggle',
36 'wp_ajax_npquickEditLink',
37 'wp_ajax_npnewLink',
38 'wp_ajax_npgetTaxonomies',
39 'wp_ajax_npnewChild',
40 'admin_post_npListingSort',
41 'wp_ajax_npEmptyTrash',
42 'admin_post_npSearch'
43 );
44 $this->setHandlers();
45 }
46
47 /**
48 * Set the Handlers Object
49 */
50 public function setHandlers()
51 {
52 foreach($this->actions as $key => $action){
53 $class = str_replace('admin_post_np', '', $action); // Non-AJAX forms
54 $class = ucfirst(str_replace('wp_ajax_np', '', $class)) . 'Handler'; // AJAX forms
55 $this->handlers[$key] = new \stdClass();
56 $this->handlers[$key]->action = $action;
57 $this->handlers[$key]->class = 'NestedPages\Form\Handlers\\' . $class;
58 }
59 $this->build();
60 }
61
62 /**
63 * Register the WP Actions
64 */
65 public function build()
66 {
67 foreach($this->handlers as $handler){
68 add_action($handler->action, function() use ($handler) {
69 new $handler->class;
70 });
71 }
72 }
73
74 }