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 / option-query / legacy-generator-query.php
jetformbuilder / modules / option-query Last commit date
interfaces 2 years ago traits 2 years ago legacy-generator-query.php 2 years ago manual-query.php 2 years ago meta-query.php 2 years ago module.php 2 years ago posts-query.php 2 years ago terms-query.php 2 years ago
legacy-generator-query.php
96 lines
1 <?php
2
3
4 namespace JFB_Modules\Option_Query;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die;
9 }
10
11 use Jet_Form_Builder\Generators;
12 use Jet_Form_Builder\Blocks\Types;
13 use Jet_Form_Builder\Plugin;
14 use JFB_Modules\Option_Query\Interfaces\Option_Query_It;
15 use JFB_Modules\Option_Query\Traits\Option_Query_Trait;
16
17 class Legacy_Generator_Query implements Option_Query_It {
18
19 use Option_Query_Trait;
20
21 /**
22 * @var Types\Base
23 */
24 private $block;
25
26 public function __construct() {
27 $this->disable_feature( 'search' );
28 }
29
30 public function rep_item_id() {
31 return 'generate';
32 }
33
34 public function fetch(): \Generator {
35 /** @var Generators\Base $generator_instance */
36
37 $generator = $this->get_setting( 'generator_function' );
38 $generators = Plugin::instance()->form->get_options_generators();
39 $generator_instance = $generators[ $generator ] ?? false;
40
41 if ( ! $generator_instance ) {
42 return;
43 }
44
45 $generator_instance->set_block( $this->get_block() );
46 $generated = $generator_instance->get_values( $this->get_settings() );
47 $generator_instance->clear_block();
48
49 $value_from = $this->get_setting( 'value_from' );
50 $calc_from = $this->get_setting( 'calc_from' );
51
52 foreach ( $generated as $key => $item ) {
53
54 if ( ! $value_from && ! $calc_from ) {
55 yield $item;
56 continue;
57 }
58
59 if ( ! is_array( $item ) ) {
60 $item = array(
61 'value' => $key,
62 'label' => $item,
63 );
64 }
65
66 $item['object_id'] = $item['value'];
67
68 if ( ! empty( $value_from ) ) {
69 $item['value'] = get_post_meta( $item['object_id'], $value_from, true );
70 }
71
72 if ( ! empty( $calc_from ) ) {
73 $item['calculate'] = get_post_meta( $item['object_id'], $calc_from, true );
74 }
75
76 yield $item;
77
78 }
79 }
80
81 /**
82 * @return Types\Base
83 */
84 public function get_block(): Types\Base {
85 return $this->block;
86 }
87
88 /**
89 * @param Types\Base $block
90 */
91 public function set_block( Types\Base $block ) {
92 $this->block = $block;
93 }
94
95 }
96