| 1 |
<?php |
| 2 |
namespace FileBird\Support; |
| 3 |
|
| 4 |
use FileBird\Controller\Folder; |
| 5 |
|
| 6 |
defined( 'ABSPATH' ) || exit; |
| 7 |
|
| 8 |
class PageBuilders { |
| 9 |
protected $folderController; |
| 10 |
|
| 11 |
public function __construct() { |
| 12 |
$this->folderController = Folder::getInstance(); |
| 13 |
add_action( 'init', array( $this, 'prepareRegister' ) ); |
| 14 |
} |
| 15 |
|
| 16 |
public function prepareRegister() { |
| 17 |
// Compatible for Elementor |
| 18 |
if ( defined( 'ELEMENTOR_VERSION' ) ) { |
| 19 |
$this->registerForElementor(); |
| 20 |
} |
| 21 |
// Compatible for WPBakery - Work normally |
| 22 |
|
| 23 |
// Compatible for Beaver Builder |
| 24 |
if ( class_exists( 'FLBuilderLoader' ) ) { |
| 25 |
$this->registerForBeaver(); |
| 26 |
} |
| 27 |
|
| 28 |
// Brizy Builder |
| 29 |
if ( class_exists( 'Brizy_Editor' ) ) { |
| 30 |
$this->registerForBrizy(); |
| 31 |
} |
| 32 |
|
| 33 |
// Cornerstone |
| 34 |
if ( class_exists( 'Cornerstone_Plugin' ) ) { |
| 35 |
$this->registerCornerstone(); |
| 36 |
} |
| 37 |
|
| 38 |
// Compatible for Divi |
| 39 |
if ( class_exists( 'ET_Builder_Element' ) ) { |
| 40 |
$this->registerForDivi(); |
| 41 |
} |
| 42 |
|
| 43 |
// Compatible for Thrive |
| 44 |
if ( defined( 'TVE_IN_ARCHITECT' ) || class_exists( 'Thrive_Quiz_Builder' ) ) { |
| 45 |
$this->registerForThrive(); |
| 46 |
} |
| 47 |
|
| 48 |
// Fusion Builder |
| 49 |
if ( class_exists( 'Fusion_Builder_Front' ) ) { |
| 50 |
$this->registerForFusion(); |
| 51 |
} |
| 52 |
|
| 53 |
// Avada Theme |
| 54 |
if ( ! class_exists( 'Fusion_Builder_Front' ) && defined( 'AVADA_VERSION' ) ) { |
| 55 |
$this->registerAvada(); |
| 56 |
} |
| 57 |
|
| 58 |
// Oxygen Builder |
| 59 |
if ( defined( 'CT_VERSION' ) ) { |
| 60 |
$this->registerOxygenBuilder(); |
| 61 |
} |
| 62 |
|
| 63 |
// Tatsu Builder |
| 64 |
if ( defined( 'TATSU_VERSION' ) ) { |
| 65 |
$this->registerTatsuBuilder(); |
| 66 |
} |
| 67 |
|
| 68 |
// Dokan plugin |
| 69 |
if ( defined( 'DOKAN_PLUGIN_VERSION' ) ) { |
| 70 |
$this->registerForDokan(); |
| 71 |
} |
| 72 |
|
| 73 |
// Themify |
| 74 |
if ( defined( 'THEMIFY_VERSION' ) && class_exists( 'Themify_Builder_Model' ) ) { |
| 75 |
$this->registerThemify(); |
| 76 |
} |
| 77 |
|
| 78 |
// Bricks |
| 79 |
if ( defined( 'BRICKS_VERSION' ) ) { |
| 80 |
$this->registerBricksBuilder(); |
| 81 |
} |
| 82 |
|
| 83 |
// BeTheme |
| 84 |
if ( defined( 'MFN_THEME_VERSION' ) ) { |
| 85 |
$this->registerBeBuilder(); |
| 86 |
} |
| 87 |
|
| 88 |
// LearnPress |
| 89 |
if ( class_exists( 'LP_Addon_Frontend_Editor_Preload' ) ) { |
| 90 |
$this->registerLearnPress(); |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
public function enqueueScripts( $is_enqueue_media = false, $is_enqueue_footer = false ) { |
| 95 |
if ( $is_enqueue_media ) { |
| 96 |
wp_enqueue_media(); |
| 97 |
|
| 98 |
} |
| 99 |
|
| 100 |
if ( $is_enqueue_footer ) { |
| 101 |
add_action( |
| 102 |
'wp_footer', |
| 103 |
function() { |
| 104 |
$this->folderController->enqueueAdminScripts( 'pagebuilders' ); |
| 105 |
} |
| 106 |
); |
| 107 |
} |
| 108 |
|
| 109 |
$this->folderController->enqueueAdminScripts( 'pagebuilders' ); |
| 110 |
} |
| 111 |
|
| 112 |
public function registerForElementor() { |
| 113 |
add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'enqueueScripts' ) ); |
| 114 |
} |
| 115 |
|
| 116 |
public function registerForBeaver() { |
| 117 |
add_action( |
| 118 |
'fl_before_sortable_enqueue', |
| 119 |
function() { |
| 120 |
$this->enqueueScripts( false, true ); |
| 121 |
} |
| 122 |
); |
| 123 |
} |
| 124 |
|
| 125 |
public function registerForBrizy() { |
| 126 |
add_action( 'brizy_editor_enqueue_scripts', array( $this, 'enqueueScripts' ) ); |
| 127 |
} |
| 128 |
|
| 129 |
public function registerCornerstone() { |
| 130 |
add_action( 'cornerstone_before_wp_editor', array( $this, 'enqueueScripts' ) ); |
| 131 |
} |
| 132 |
|
| 133 |
public function registerForDivi() { |
| 134 |
add_action( |
| 135 |
'et_fb_enqueue_assets', |
| 136 |
function() { |
| 137 |
$this->enqueueScripts(); |
| 138 |
} |
| 139 |
); |
| 140 |
} |
| 141 |
|
| 142 |
public function registerForThrive() { |
| 143 |
add_action( 'tcb_main_frame_enqueue', array( $this, 'enqueueScripts' ) ); |
| 144 |
} |
| 145 |
|
| 146 |
public function registerForFusion() { |
| 147 |
add_action( 'fusion_builder_enqueue_live_scripts', array( $this, 'enqueueScripts' ) ); |
| 148 |
} |
| 149 |
|
| 150 |
public function registerOxygenBuilder() { |
| 151 |
add_action( 'oxygen_enqueue_ui_scripts', array( $this, 'enqueueScripts' ) ); |
| 152 |
} |
| 153 |
|
| 154 |
public function registerTatsuBuilder() { |
| 155 |
add_action( 'tatsu_builder_footer', array( $this, 'enqueueScripts' ) ); |
| 156 |
} |
| 157 |
|
| 158 |
public function registerForDokan() { |
| 159 |
add_action( |
| 160 |
'dokan_enqueue_scripts', |
| 161 |
function() { |
| 162 |
if ( function_exists( 'dokan_is_seller_dashboard' ) ) { |
| 163 |
if ( ( dokan_is_seller_dashboard() || ( get_query_var( 'edit' ) && is_singular( 'product' ) ) ) || apply_filters( 'dokan_forced_load_scripts', false ) ) { |
| 164 |
$this->enqueueScripts(); |
| 165 |
} |
| 166 |
} |
| 167 |
} |
| 168 |
); |
| 169 |
} |
| 170 |
|
| 171 |
public function registerThemify() { |
| 172 |
add_action( |
| 173 |
'wp_ajax_tb_load_editor', |
| 174 |
function() { |
| 175 |
$this->enqueueScripts( true ); |
| 176 |
}, |
| 177 |
9 |
| 178 |
); |
| 179 |
} |
| 180 |
|
| 181 |
public function registerBricksBuilder() { |
| 182 |
if ( function_exists( 'bricks_is_builder' ) && \bricks_is_builder() ) { |
| 183 |
add_action( 'bricks_after_footer', array( $this, 'enqueueScripts' ) ); |
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
public function registerAvada() { |
| 188 |
add_action( 'fusion_enqueue_live_scripts', array( $this, 'enqueueScripts' ) ); |
| 189 |
} |
| 190 |
|
| 191 |
public function registerBeBuilder() { |
| 192 |
add_action( |
| 193 |
'admin_enqueue_scripts', |
| 194 |
function() { |
| 195 |
if ( ! wp_script_is( 'mfn-vbscripts', 'enqueued' ) ) { |
| 196 |
return; |
| 197 |
} |
| 198 |
|
| 199 |
$this->enqueueScripts(); |
| 200 |
}, |
| 201 |
PHP_INT_MAX |
| 202 |
); |
| 203 |
|
| 204 |
add_action( |
| 205 |
'wp_enqueue_scripts', |
| 206 |
function() { |
| 207 |
if ( ! wp_script_is( 'mfn-vbscripts', 'enqueued' ) ) { |
| 208 |
return; |
| 209 |
} |
| 210 |
|
| 211 |
$this->enqueueScripts(); |
| 212 |
}, |
| 213 |
PHP_INT_MAX |
| 214 |
); |
| 215 |
} |
| 216 |
|
| 217 |
public function registerLearnPress() { |
| 218 |
add_action( 'learnpress/addons/frontend_editor/enqueue_scripts', array( $this, 'enqueueScripts' ) ); |
| 219 |
} |
| 220 |
} |