* * @since 1.0.0 * @access public * * @param string $content The content of the builder. * * @return string HTML wrapper for the builder. */ public function builder_wrapper( $content ) { if ( get_the_ID() === $this->post_id ) { $document = Plugin::$instance->documents->get( $this->post_id ); $attributes = $document->get_container_attributes(); $content = '
'; } return $content; } /** * Enqueue preview styles. * * Registers all the preview styles and enqueues them. * * Fired by `wp_enqueue_scripts` action. * * @since 1.0.0 * @access private */ private function enqueue_styles() { // Hold-on all jQuery plugins after all HTML markup render. wp_add_inline_script( 'jquery-migrate', 'jQuery.holdReady( true );' ); Plugin::$instance->frontend->enqueue_styles(); Plugin::$instance->widgets_manager->enqueue_widgets_styles(); $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; $direction_suffix = is_rtl() ? '-rtl' : ''; wp_register_style( 'elementor-select2', ELEMENTOR_ASSETS_URL . 'lib/e-select2/css/e-select2' . $suffix . '.css', [], '4.0.6-rc.1' ); wp_register_style( 'editor-preview', ELEMENTOR_ASSETS_URL . 'css/editor-preview' . $direction_suffix . $suffix . '.css', [ 'elementor-select2', ], ELEMENTOR_VERSION ); wp_enqueue_style( 'e-theme-ui-light', $this->get_css_assets_url( 'theme-light' ), [], ELEMENTOR_VERSION ); wp_enqueue_style( 'editor-preview' ); if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { wp_register_style( 'editor-preview-legacy', ELEMENTOR_ASSETS_URL . 'css/editor-preview-legacy' . $direction_suffix . $suffix . '.css', [], ELEMENTOR_VERSION ); wp_enqueue_style( 'editor-preview-legacy' ); } // Handle the 'wp audio' in editor preview. wp_enqueue_style( 'wp-mediaelement' ); /** * Preview enqueue styles. * * Fires after Elementor preview styles are enqueued. * * @since 1.0.0 */ do_action( 'elementor/preview/enqueue_styles' ); } /** * Enqueue preview scripts. * * Registers all the preview scripts and enqueues them. * * Fired by `wp_enqueue_scripts` action. * * @since 1.5.4 * @access private */ private function enqueue_scripts() { Plugin::$instance->frontend->register_scripts(); Plugin::$instance->widgets_manager->enqueue_widgets_scripts(); $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script( 'elementor-inline-editor', ELEMENTOR_ASSETS_URL . 'lib/inline-editor/js/inline-editor' . $suffix . '.js', [], ELEMENTOR_VERSION, true ); // Handle the 'wp audio' in editor preview. wp_enqueue_script( 'wp-mediaelement' ); /** * Preview enqueue scripts. * * Fires after Elementor preview scripts are enqueued. * * @since 1.5.4 */ do_action( 'elementor/preview/enqueue_scripts' ); } public function rocket_loader_filter( $tag, $handle, $src ) { return str_replace( 'frontend; if ( $frontend->has_elementor_in_page() ) { // Has header/footer/widget-template - enqueue all style/scripts/fonts. $frontend->wp_footer(); } else { // Enqueue only scripts. $frontend->enqueue_scripts(); } } /** * Preview constructor. * * Initializing Elementor preview. * * @since 1.0.0 * @access public */ public function __construct() { add_action( 'template_redirect', [ $this, 'init' ], 0 ); } }