page-builders.php
66 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Page Builder. |
| 4 | * |
| 5 | * @package sureforms. |
| 6 | * @since 0.0.5 |
| 7 | */ |
| 8 | |
| 9 | namespace SRFM\Inc\Page_Builders; |
| 10 | |
| 11 | use SRFM\Inc\Frontend_Assets; |
| 12 | use SRFM\Inc\Page_Builders\Bricks\Service_Provider as Bricks_Service_Provider; |
| 13 | use SRFM\Inc\Page_Builders\Elementor\Service_Provider as Elementor_Service_Provider; |
| 14 | use SRFM\Inc\Traits\Get_Instance; |
| 15 | |
| 16 | /** |
| 17 | * Class to add SureForms widget in other page builders. |
| 18 | */ |
| 19 | class Page_Builders { |
| 20 | use Get_Instance; |
| 21 | |
| 22 | /** |
| 23 | * Constructor |
| 24 | * |
| 25 | * Load all Page Builders form widgets. |
| 26 | * |
| 27 | * @since 0.0.5 |
| 28 | * @return void |
| 29 | */ |
| 30 | public function __construct() { |
| 31 | Elementor_Service_Provider::get_instance(); |
| 32 | Bricks_Service_Provider::get_instance(); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Enqueue common fields assets for the dropdown and phone fields. |
| 37 | * |
| 38 | * @since 0.0.10 |
| 39 | * @return void |
| 40 | */ |
| 41 | public static function enqueue_common_fields_assets() { |
| 42 | $file_prefix = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? '' : '.min'; |
| 43 | $dir_name = defined( 'SRFM_DEBUG' ) && SRFM_DEBUG ? 'unminified' : 'minified'; |
| 44 | $js_uri = SRFM_URL . 'assets/js/' . $dir_name . '/blocks/'; |
| 45 | $js_vendor_uri = SRFM_URL . 'assets/js/minified/deps/'; |
| 46 | |
| 47 | wp_enqueue_script( SRFM_SLUG . '-phone', $js_uri . 'phone' . $file_prefix . '.js', [], SRFM_VER, true ); |
| 48 | wp_enqueue_script( SRFM_SLUG . '-phone-intl-input-deps', $js_vendor_uri . 'intl/intTelInputWithUtils.min.js', [], SRFM_VER, true ); |
| 49 | |
| 50 | wp_enqueue_script( SRFM_SLUG . '-dropdown', $js_uri . 'dropdown' . $file_prefix . '.js', [ 'wp-a11y' ], SRFM_VER, true ); |
| 51 | wp_enqueue_script( SRFM_SLUG . '-tom-select', $js_vendor_uri . 'tom-select.min.js', [], SRFM_VER, true ); |
| 52 | |
| 53 | if ( defined( 'SRFM_PRO_VER' ) && defined( 'SRFM_PRO_URL' ) && defined( 'SRFM_PRO_SLUG' ) ) { |
| 54 | $css_uri = SRFM_PRO_URL . 'assets/css/' . $dir_name . '/'; |
| 55 | |
| 56 | wp_enqueue_style( SRFM_PRO_SLUG . '-frontend-default', $css_uri . '/blocks/default/frontend' . $file_prefix . '.css', [], SRFM_PRO_VER ); |
| 57 | } |
| 58 | |
| 59 | Frontend_Assets::enqueue_scripts_and_styles(); |
| 60 | |
| 61 | // Action to enqueue common field assets. |
| 62 | do_action( 'srfm_enqueue_common_field_assets' ); |
| 63 | } |
| 64 | |
| 65 | } |
| 66 |