namespace Elementor\Core\Common;
use Elementor\Core\Base\App as BaseApp;
use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
use Elementor\Core\Common\Modules\Finder\Module as Finder;
use Elementor\Core\Common\Modules\Connect\Module as Connect;
use Elementor\Core\Common\Modules\EventTracker\Module as Event_Tracker;
use Elementor\Core\Common\Modules\EventsManager\Module as Events_Manager;
use Elementor\Core\Files\Uploads_Manager;
use Elementor\Icons_Manager;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
* Elementor's common app that groups shared functionality, components and configuration
class App extends BaseApp {
public function __construct() {
$this->add_default_templates();
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'register_scripts' ], 9 );
add_action( 'admin_enqueue_scripts', [ $this, 'register_scripts' ], 9 );
add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ], 9 );
add_action( 'elementor/editor/before_enqueue_styles', [ $this, 'register_styles' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'register_styles' ] );
add_action( 'wp_enqueue_scripts', [ $this, 'register_styles' ], 9 );
add_action( 'elementor/editor/footer', [ $this, 'print_templates' ] );
add_action( 'admin_footer', [ $this, 'print_templates' ] );
add_action( 'wp_footer', [ $this, 'print_templates' ] );
* Initializing common components.
public function init_components() {
$this->add_component( 'ajax', new Ajax() );
if ( current_user_can( 'manage_options' ) ) {
if ( ! is_customize_preview() ) {
$this->add_component( 'finder', new Finder() );
$this->add_component( 'connect', new Connect() );
$this->add_component( 'event-tracker', new Event_Tracker() );
Plugin::$instance->experiments->add_feature( Events_Manager::get_experimental_data() );
if ( Plugin::$instance->experiments->is_feature_active( Events_Manager::EXPERIMENT_NAME ) ) {
$this->add_component( 'events-manager', new Events_Manager() );
* @return string Common app name.
public function get_name() {
* Register common scripts.
public function register_scripts() {
'elementor-common-modules',
$this->get_js_assets_url( 'common-modules' ),
$this->get_js_assets_url( 'backbone.marionette', 'assets/lib/backbone/' ),
$this->get_js_assets_url( 'backbone.radio', 'assets/lib/backbone/' ),
$this->get_js_assets_url( 'dialog', 'assets/lib/dialog/' ),
$this->get_js_assets_url( 'common' ),
'elementor-common-modules',
wp_set_script_translations( 'elementor-common', 'elementor' );
// Used for external plugins.
do_action( 'elementor/common/after_register_scripts', $this );
* Register common styles.
public function register_styles() {
$this->get_css_assets_url( 'elementor-icons', 'assets/lib/eicons/css/' ),
Icons_Manager::ELEMENTOR_ICONS_VERSION
$this->get_css_assets_url( 'common', null, 'default', true ),
$this->get_css_assets_url( 'theme-light' ),
* @param string $template Can be either a link to template file or template
* @param string $type Optional. Whether to handle the template as path
* or text. Default is `path`.
public function add_template( $template, $type = 'path' ) {
if ( 'path' === $type ) {
$template = ob_get_clean();
$this->templates[] = $template;
* Prints all registered templates.
public function print_templates() {
foreach ( $this->templates as $template ) {
echo $template; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
* Define the default/initial settings of the common app.
protected function get_init_settings() {
$active_experimental_features = Plugin::$instance->experiments->get_active_features();
$all_experimental_features = Plugin::$instance->experiments->get_features();
$active_experimental_features = array_fill_keys( array_keys( $active_experimental_features ), true );
$all_experimental_features = array_map(
return Plugin::$instance->experiments->is_feature_active( $feature['name'] );
$all_experimental_features
'version' => ELEMENTOR_VERSION,
'isDebug' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ),
'isElementorDebug' => Utils::is_elementor_debug(),
'activeModules' => array_keys( $this->get_components() ),
'experimentalFeatures' => $active_experimental_features,
'allExperimentalFeatures' => $all_experimental_features,
'assets' => ELEMENTOR_ASSETS_URL,
'rest' => get_rest_url(),
'unfilteredFiles' => Uploads_Manager::are_unfiltered_uploads_enabled(),
'editor_events' => Events_Manager::get_editor_events_config(),
* Localize common settings.
* Filters the editor localized settings.
* @param array $config Common configuration.
return apply_filters( 'elementor/common/localize_settings', $config );
* Register common app default templates.
private function add_default_templates() {
'includes/editor-templates/library-layout.php',
foreach ( $default_templates as $template ) {
$this->add_template( ELEMENTOR_PATH . $template );