PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.4
JetFormBuilder — Dynamic Blocks Form Builder v3.5.4
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 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.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / actions-v2 / insert-term / insert-term-action.php
jetformbuilder / modules / actions-v2 / insert-term Last commit date
assets 1 year ago properties 1 year ago insert-term-action.php 1 year ago insert-term.php 1 year ago
insert-term-action.php
164 lines
1 <?php
2
3 namespace JFB_Modules\Actions_V2\Insert_Term;
4
5 use Jet_Form_Builder\Actions\Action_Handler;
6 use JFB_Modules\Actions_V2\Insert_Term\Properties\Abstract_Term_Modifier;
7 use JFB_Modules\Actions_V2\Insert_Term\Properties\Term_Modifier;
8 use Jet_Form_Builder\Actions\Types\Base;
9 use Jet_Form_Builder\Classes\Arrayable\Array_Tools;
10 use Jet_Form_Builder\Classes\Tools;
11
12 // If this file is called directly, abort.
13 if ( ! defined( 'WPINC' ) ) {
14 die;
15 }
16
17 /**
18 * Define Base_Type class
19 */
20 class Insert_Term_Action extends Base {
21
22 public function get_name() {
23 return __( 'Insert/Update Term', 'jet-form-builder' );
24 }
25
26 public function get_id() {
27 return 'insert_term';
28 }
29
30 public function action_attributes() {
31 return array(
32 'taxonomy' => array(
33 'default' => '',
34 ),
35 'fields_map' => array(
36 'default' => array(),
37 ),
38 'default_meta' => array(
39 'default' => array(),
40 ),
41 );
42 }
43
44 /**
45 * @param array $request
46 * @param Action_Handler $handler
47 *
48 * @return void
49 */
50 public function do_action( array $request, Action_Handler $handler ) {
51 $modifiers = array_reverse( $this->get_modifiers() );
52
53 /** @var Abstract_Term_Modifier $modifier */
54 foreach ( $modifiers as $modifier ) {
55 if ( ! $modifier->is_supported( $this ) ) {
56 continue;
57 }
58
59 $modifier->before_run( $this );
60 $modifier->run();
61 break;
62 }
63 }
64
65 public function get_taxonomy(): string {
66 return $this->settings['taxonomy'] ?? '';
67 }
68
69 public static function get_context_term_key( $term_id ) {
70 return "term-id-{$term_id}";
71 }
72
73 public function editor_labels() {
74 return array(
75 'taxonomy' => __( 'Taxonomy:', 'jet-form-builder' ),
76 'fields_map' => __( 'Fields Map:', 'jet-form-builder' ),
77 );
78 }
79
80 // public function editor_labels_help() {
81 // return array(
82 // 'fields_map' => __( 'Set meta fields names or term properties to save appropriate form fields into', 'jet-form-builder' ),
83 // 'default_meta' => __( 'Set default meta values which should be set on term insert/update', 'jet-form-builder' ),
84 // );
85 // }
86
87 /**
88 * Regsiter custom action data for the editor
89 *
90 * @return [type] [description]
91 */
92 public function action_data() {
93 $properties = array();
94 $modifiers = $this->get_modifiers();
95
96 foreach ( $modifiers as $modifier ) {
97 $properties[ $modifier->get_id() ] = Tools::with_placeholder(
98 Array_Tools::to_array( $modifier->properties->all() )
99 );
100 }
101
102 return array(
103 'taxonomies' => Tools::get_taxonomies_for_modify(),
104 'properties' => $properties,
105 );
106 }
107
108 /**
109 * Just add a new element to the end.
110 * When the action is executed, this array is flipped,
111 * which puts the \Jet_Form_Builder\Actions\Methods\Post_Modifier at the end.
112 *
113 * @return Abstract_Post_Modifier[]
114 * @since 2.1.4
115 */
116 public function get_modifiers(): array {
117 return apply_filters(
118 'jet-form-builder/action/insert-term/modifiers',
119 array(
120 new Term_Modifier(),
121 )
122 );
123 }
124
125 /**
126 * Returns post statuses list for the options
127 *
128 * @return array
129 */
130 // public function get_post_statuses_for_options() {
131
132 // $statuses = get_post_statuses();
133 // $result = array();
134
135 // foreach ( $statuses as $name => $label ) {
136 // $result[] = array(
137 // 'value' => $name,
138 // 'label' => $label,
139 // );
140 // }
141
142 // $result = array_merge(
143 // $result,
144 // array(
145 // array(
146 // 'value' => 'trash',
147 // 'label' => __( 'Move to Trash', 'jet-form-builder' ),
148 // ),
149 // array(
150 // 'value' => 'from-field',
151 // 'label' => __( 'Get from the form field', 'jet-form-builder' ),
152 // ),
153 // array(
154 // 'value' => 'keep-current',
155 // 'label' => __( 'Keep current status (when updating post)', 'jet-form-builder' ),
156 // ),
157 // )
158 // );
159
160 // return Tools::with_placeholder( apply_filters( 'jet-form-builder/actions/insert-post/allowed-post-statuses', $result ) );
161 // }
162
163 }
164