| 1 |
<?php |
| 2 |
namespace FileBird\Support; |
| 3 |
|
| 4 |
use FileBird\Classes\Core; |
| 5 |
|
| 6 |
defined( 'ABSPATH' ) || exit; |
| 7 |
|
| 8 |
class PageBuilders { |
| 9 |
protected $core; |
| 10 |
|
| 11 |
public function __construct() { |
| 12 |
$this->core = Core::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 |
// Break Dance Builder |
| 94 |
if ( defined( '__BREAKDANCE_VERSION' ) ) { |
| 95 |
$this->registerBreakDance(); |
| 96 |
} |
| 97 |
|
| 98 |
// YooTheme |
| 99 |
if ( class_exists( 'YOOtheme\Builder' ) ) { |
| 100 |
$this->registerYooTheme(); |
| 101 |
} |
| 102 |
|
| 103 |
// Zion Builder |
| 104 |
if ( class_exists( 'ZionBuilder\Plugin' ) || function_exists( 'znb_kallyas_integration' ) ) { |
| 105 |
$this->registerZionBuilder(); |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
public function enqueueScripts( $is_enqueue_media = false, $is_enqueue_footer = false ) { |
| 110 |
if ( $is_enqueue_media ) { |
| 111 |
wp_enqueue_media(); |
| 112 |
|
| 113 |
} |
| 114 |
|
| 115 |
if ( $is_enqueue_footer ) { |
| 116 |
add_action( |
| 117 |
'wp_footer', |
| 118 |
function() { |
| 119 |
$this->core->enqueueAdminScripts( 'pagebuilders' ); |
| 120 |
} |
| 121 |
); |
| 122 |
} |
| 123 |
|
| 124 |
$this->core->enqueueAdminScripts( 'pagebuilders' ); |
| 125 |
} |
| 126 |
|
| 127 |
public function registerForElementor() { |
| 128 |
add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'enqueueScripts' ) ); |
| 129 |
} |
| 130 |
|
| 131 |
public function registerForBeaver() { |
| 132 |
add_action( |
| 133 |
'fl_before_sortable_enqueue', |
| 134 |
function() { |
| 135 |
$this->enqueueScripts( false, true ); |
| 136 |
} |
| 137 |
); |
| 138 |
} |
| 139 |
|
| 140 |
public function registerForBrizy() { |
| 141 |
add_action( 'brizy_editor_enqueue_scripts', array( $this, 'enqueueScripts' ) ); |
| 142 |
} |
| 143 |
|
| 144 |
public function registerCornerstone() { |
| 145 |
add_action( 'cornerstone_before_wp_editor', array( $this, 'enqueueScripts' ) ); |
| 146 |
} |
| 147 |
|
| 148 |
public function registerForDivi() { |
| 149 |
add_action( |
| 150 |
'et_fb_enqueue_assets', |
| 151 |
function() { |
| 152 |
$this->enqueueScripts(); |
| 153 |
} |
| 154 |
); |
| 155 |
} |
| 156 |
|
| 157 |
public function registerForThrive() { |
| 158 |
add_action( 'tcb_main_frame_enqueue', array( $this, 'enqueueScripts' ) ); |
| 159 |
} |
| 160 |
|
| 161 |
public function registerForFusion() { |
| 162 |
add_action( 'fusion_builder_enqueue_live_scripts', array( $this, 'enqueueScripts' ) ); |
| 163 |
} |
| 164 |
|
| 165 |
public function registerOxygenBuilder() { |
| 166 |
add_action( 'oxygen_enqueue_ui_scripts', array( $this, 'enqueueScripts' ) ); |
| 167 |
} |
| 168 |
|
| 169 |
public function registerTatsuBuilder() { |
| 170 |
add_action( 'tatsu_builder_footer', array( $this, 'enqueueScripts' ) ); |
| 171 |
} |
| 172 |
|
| 173 |
public function registerForDokan() { |
| 174 |
add_action( |
| 175 |
'dokan_enqueue_scripts', |
| 176 |
function() { |
| 177 |
if ( function_exists( 'dokan_is_seller_dashboard' ) ) { |
| 178 |
if ( ( dokan_is_seller_dashboard() || ( get_query_var( 'edit' ) && is_singular( 'product' ) ) ) || apply_filters( 'dokan_forced_load_scripts', false ) ) { |
| 179 |
$this->enqueueScripts(); |
| 180 |
} |
| 181 |
} |
| 182 |
} |
| 183 |
); |
| 184 |
} |
| 185 |
|
| 186 |
public function registerThemify() { |
| 187 |
add_action( |
| 188 |
'wp_ajax_tb_load_editor', |
| 189 |
function() { |
| 190 |
wp_enqueue_script( 'filebird-themify', NJFB_PLUGIN_URL . 'assets/js/themify.js', array(), NJFB_VERSION, true ); |
| 191 |
$this->enqueueScripts( true ); |
| 192 |
}, |
| 193 |
9 |
| 194 |
); |
| 195 |
} |
| 196 |
|
| 197 |
public function registerBricksBuilder() { |
| 198 |
if ( function_exists( 'bricks_is_builder' ) && \bricks_is_builder() ) { |
| 199 |
add_action( 'bricks_after_footer', array( $this, 'enqueueScripts' ) ); |
| 200 |
} |
| 201 |
} |
| 202 |
|
| 203 |
public function registerAvada() { |
| 204 |
add_action( 'fusion_enqueue_live_scripts', array( $this, 'enqueueScripts' ) ); |
| 205 |
} |
| 206 |
|
| 207 |
public function registerBeBuilder() { |
| 208 |
if ( is_admin() ) { |
| 209 |
add_action( |
| 210 |
'mfn_footer_enqueue', |
| 211 |
function() { |
| 212 |
$this->enqueueScripts(); |
| 213 |
} |
| 214 |
); |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
public function registerLearnPress() { |
| 219 |
add_action( 'learnpress/addons/frontend_editor/enqueue_scripts', array( $this, 'enqueueScripts' ) ); |
| 220 |
} |
| 221 |
|
| 222 |
public function registerBreakDance() { |
| 223 |
if ( isset( $_GET['breakdance_wpuiforbuilder_media'] ) && $_GET['breakdance_wpuiforbuilder_media'] ) { |
| 224 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueueScripts' ), 9 ); |
| 225 |
} |
| 226 |
} |
| 227 |
|
| 228 |
public function registerYooTheme() { |
| 229 |
add_action( 'admin_print_footer_scripts-yootheme_customizer', array( $this, 'enqueueScripts' ) ); |
| 230 |
} |
| 231 |
|
| 232 |
public function registerZionBuilder() { |
| 233 |
if ( class_exists( 'ZionBuilder\Plugin' ) ) { |
| 234 |
add_action( 'zionbuilder/editor/before_scripts', array( $this, 'enqueueScripts' ) ); |
| 235 |
} |
| 236 |
|
| 237 |
if ( function_exists( 'znb_kallyas_integration' ) ) { |
| 238 |
add_action( 'znpb_editor_after_load_scripts', array( $this, 'enqueueScripts' ) ); |
| 239 |
} |
| 240 |
} |
| 241 |
} |