PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.1.1
JetFormBuilder — Dynamic Blocks Form Builder v2.1.1
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 / includes / generators / get-from-field.php
jetformbuilder / includes / generators Last commit date
je-query-object-handlers 3 years ago base.php 3 years ago get-from-db.php 3 years ago get-from-field.php 3 years ago get-from-je-query.php 3 years ago num-range-manual.php 3 years ago num-range.php 3 years ago
get-from-field.php
77 lines
1 <?php
2
3 namespace Jet_Form_Builder\Generators;
4
5 class Get_From_Field extends Base {
6
7 /**
8 * Returns generator ID
9 *
10 * @return string
11 */
12 public function get_id() {
13 return 'get_from_field';
14 }
15
16 /**
17 * Returns generator name
18 *
19 * @return string
20 */
21 public function get_name() {
22 return __( 'Get values list from JetEngine field options', 'jet-form-builder' );
23 }
24
25 public function can_generate() {
26 return function_exists( 'jet_engine' );
27 }
28
29 /**
30 * Returns generated options list
31 *
32 * @param $args
33 *
34 * @return array
35 */
36 public function generate( $args ) {
37 $field = $args['generator_field'] ?? '';
38 $all_fields = jet_engine()->meta_boxes->get_registered_fields();
39 $found_field = null;
40 $result = array();
41 $parse_field = explode( '|', $field );
42 $field = $parse_field[0];
43 $sub_field = isset( $parse_field[1] ) ? $parse_field[1] : false;
44
45 foreach ( $all_fields as $object => $fields ) {
46 foreach ( $fields as $field_data ) {
47 if ( ! empty( $field_data['name'] ) && $field === $field_data['name'] ) {
48 $found_field = $field_data;
49 }
50 }
51 }
52
53 if ( ! empty( $sub_field ) && ! empty( $found_field['repeater-fields'] ) ) {
54 foreach ( $found_field['repeater-fields'] as $repeater_field_data ) {
55 if ( ! empty( $repeater_field_data['name'] ) && $sub_field === $repeater_field_data['name'] ) {
56 $found_field = $repeater_field_data;
57 }
58 }
59 }
60
61 if ( empty( $found_field['options'] ) ) {
62 return $result;
63 }
64
65 foreach ( $found_field['options'] as $option ) {
66 $result[] = array(
67 'value' => $option['key'],
68 'label' => $option['value'],
69 );
70 }
71
72 return $result;
73
74 }
75
76 }
77