| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace JFB_Compatibility\Jet_Engine\Option_Query; |
| 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_Modules\Option_Query\Module; |
| 14 |
|
| 15 |
class Inner_Module implements \JFB_Components\Module\Base_Module_It { |
| 16 |
|
| 17 |
public function rep_item_id() { |
| 18 |
return 'je-option-query'; |
| 19 |
} |
| 20 |
|
| 21 |
public function condition(): bool { |
| 22 |
return true; |
| 23 |
} |
| 24 |
|
| 25 |
public function init_hooks() { |
| 26 |
add_action( |
| 27 |
'jet-form-builder/option-query/on-install', |
| 28 |
array( $this, 'add_option_queries' ) |
| 29 |
); |
| 30 |
// connect to the blocks |
| 31 |
add_action( |
| 32 |
'jet-form-builder/option-query/set-in-block', |
| 33 |
array( $this, 'on_set_in_block' ) |
| 34 |
); |
| 35 |
} |
| 36 |
|
| 37 |
public function remove_hooks() { |
| 38 |
remove_action( |
| 39 |
'jet-form-builder/option-query/on-install', |
| 40 |
array( $this, 'add_option_queries' ) |
| 41 |
); |
| 42 |
remove_action( |
| 43 |
'jet-form-builder/option-query/set-in-block', |
| 44 |
array( $this, 'on_set_in_block' ) |
| 45 |
); |
| 46 |
} |
| 47 |
|
| 48 |
public function add_option_queries( Module $module ) { |
| 49 |
if ( jet_engine()->glossaries ) { |
| 50 |
$module->install( new Glossary_Query() ); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* @param Base|Support_Option_Query_It $block |
| 56 |
*/ |
| 57 |
public function on_set_in_block( Base $block ) { |
| 58 |
switch ( $block->get_query()->rep_item_id() ) { |
| 59 |
case 'glossary': |
| 60 |
$block->get_query()->set_query( |
| 61 |
'id', |
| 62 |
$block->block_attrs['glossary_id'] ?? 0 |
| 63 |
); |
| 64 |
break; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
} |
| 69 |
|