PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.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 All 134 releases
jetformbuilder / compatibility / woocommerce / woocommerce.php

woocommerce.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.6, at compatibility/woocommerce/woocommerce.php

73 lines 1.8 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\Woocommerce;
5
6 use JFB_Compatibility\Woocommerce\Methods\Wc_Product_Modification\Wc_Product_Modifier;
7 use JFB_Components\Compatibility\Base_Compat_Dir_Trait;
8 use JFB_Components\Compatibility\Base_Compat_Handle_Trait;
9 use JFB_Components\Compatibility\Base_Compat_Url_Trait;
10 use JFB_Components\Module\Base_Module_Dir_It;
11 use JFB_Components\Module\Base_Module_Handle_It;
12 use JFB_Components\Module\Base_Module_It;
13 use JFB_Components\Module\Base_Module_Url_It;
14
15 // If this file is called directly, abort.
16 if ( ! defined( 'WPINC' ) ) {
17 die;
18 }
19
20 class Woocommerce implements
21 Base_Module_Url_It,
22 Base_Module_It,
23 Base_Module_Handle_It,
24 Base_Module_Dir_It {
25
26 use Base_Compat_Url_Trait;
27 use Base_Compat_Handle_Trait;
28 use Base_Compat_Dir_Trait;
29
30 public function rep_item_id() {
31 return 'woocommerce';
32 }
33
34 public function condition(): bool {
35 return function_exists( 'WC' );
36 }
37
38 public function init_hooks() {
39 add_filter(
40 'jet-form-builder/action/insert-post/modifiers',
41 array( $this, 'add_modifiers' )
42 );
43 add_action( 'jet-form-builder/editor-assets/before', array( $this, 'enqueue_admin_assets' ) );
44 }
45
46 public function remove_hooks() {
47 remove_filter(
48 'jet-form-builder/action/insert-post/modifiers',
49 array( $this, 'add_modifiers' )
50 );
51 remove_action( 'jet-form-builder/editor-assets/before', array( $this, 'enqueue_admin_assets' ) );
52 }
53
54 public function add_modifiers( array $modifiers ): array {
55 $modifiers[] = new Wc_Product_Modifier();
56
57 return $modifiers;
58 }
59
60 public function enqueue_admin_assets() {
61 $script_asset = require_once $this->get_dir( 'assets/build/editor.asset.php' );
62
63 wp_enqueue_script(
64 $this->get_handle(),
65 $this->get_url( 'assets/build/editor.js' ),
66 $script_asset['dependencies'],
67 $script_asset['version'],
68 true
69 );
70 }
71
72 }
73