PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.2
JetFormBuilder — Dynamic Blocks Form Builder v3.6.2
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 / posts-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 7 months ago meta-query.php 2 years ago module.php 2 years ago posts-query.php 2 years ago terms-query.php 2 years ago
posts-query.php
97 lines
1 <?php
2
3
4 namespace JFB_Modules\Option_Query;
5
6 use JFB_Modules\Option_Query\Interfaces\Option_Query_It;
7 use JFB_Modules\Option_Query\Traits\Option_Query_Trait;
8
9 // If this file is called directly, abort.
10 if ( ! defined( 'WPINC' ) ) {
11 die;
12 }
13
14 class Posts_Query implements Option_Query_It {
15
16 use Option_Query_Trait;
17
18 const POST_PROPS = array(
19 'post_title',
20 'post_content',
21 'post_name',
22 'post_excerpt',
23 );
24
25 public function rep_item_id() {
26 return 'posts';
27 }
28
29 public function fetch(): \Generator {
30 $post_type = $this->get_query( 'post_type' );
31
32 if ( ! $post_type ) {
33 return;
34 }
35
36 if ( ! $this->has_query( 'post_status' ) ) {
37 $this->set_query( 'post_status', 'publish' );
38 }
39
40 if ( ! $this->has_query( 'posts_per_page' ) ) {
41 $this->set_query( 'posts_per_page', - 1 );
42 }
43
44 // replace 'search' to the 's'
45 if ( $this->has_query( 'search' ) && ! $this->has_query( 's' ) ) {
46 $this->set_query( 's', $this->get_query( 'search' ) );
47 }
48 $this->delete_query( 'search' );
49
50 $posts = get_posts(
51 apply_filters_deprecated(
52 'jet-form-builder/render-choice/query-options/posts',
53 array( $this->get_query_params(), $this->get_settings() ),
54 '3.3.1',
55 'jet-form-builder/option-query/set-in-block'
56 )
57 );
58
59 if ( empty( $posts ) ) {
60 return;
61 }
62
63 foreach ( $posts as $post ) {
64
65 $item = array(
66 'object_id' => $post->ID,
67 'value' => $post->ID,
68 'label' => apply_filters( 'jet-form-builder/render-choice/label/posts', $post->post_title, $post ),
69 );
70
71 $value_from = $this->get_setting( 'value_from' );
72
73 if ( $value_from ) {
74 if ( in_array( $value_from, self::POST_PROPS, true ) ) {
75 $item['value'] = $post->$value_from;
76 } else {
77 $item['value'] = get_post_meta( $post->ID, $value_from, true );
78 }
79 }
80
81 $calc_from = $this->get_setting( 'calc_from' );
82
83 if ( ! empty( $calc_from ) ) {
84 if ( in_array( $calc_from, self::POST_PROPS, true ) ) {
85 $item['calculate'] = $post->$calc_from;
86 } else {
87 $item['calculate'] = get_post_meta( $post->ID, $calc_from, true );
88 }
89 }
90
91 yield $item;
92
93 }
94 }
95
96 }
97