PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.3
JetFormBuilder — Dynamic Blocks Form Builder v3.6.3
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.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 All 130 releases
jetformbuilder / compatibility / polylang / polylang.php
polylang.php
74 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JFB_Compatibility\Polylang;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die();
9 }
10
11 use JFB_Modules\Option_Field\Interfaces\Support_Option_Query_It;
12 use Jet_Form_Builder\Blocks\Types\Base;
13 use JFB_Components\Module\Base_Module_It;
14
15 class Polylang implements Base_Module_It {
16
17 public function rep_item_id() {
18 return 'polylang';
19 }
20
21 public function condition(): bool {
22 return function_exists( 'PLL' );
23 }
24
25 public function init_hooks() {
26 if ( ! jet_form_builder()->has_module( 'option-query' ) ) {
27 add_filter(
28 'jet-form-builder/render-choice/query-options/posts',
29 array( $this, 'remove_suppress_filters' )
30 );
31
32 return;
33 }
34
35 add_action(
36 'jet-form-builder/option-query/set-in-block',
37 array( $this, 'on_set_in_block' )
38 );
39 }
40
41 public function remove_hooks() {
42 if ( ! jet_form_builder()->has_module( 'option-query' ) ) {
43 remove_filter(
44 'jet-form-builder/render-choice/query-options/posts',
45 array( $this, 'remove_suppress_filters' )
46 );
47
48 return;
49 }
50
51 remove_action(
52 'jet-form-builder/option-query/set-in-block',
53 array( $this, 'on_set_in_block' )
54 );
55 }
56
57 public function remove_suppress_filters( array $args ): array {
58 $args['suppress_filters'] = false;
59
60 return $args;
61 }
62
63 /**
64 * @param Base|Support_Option_Query_It $block
65 */
66 public function on_set_in_block( Base $block ) {
67 switch ( $block->get_query()->rep_item_id() ) {
68 case 'posts':
69 $block->get_query()->set_query( 'suppress_filters', false );
70 break;
71 }
72 }
73 }
74