function( $request_value, $object ) { if ( ! User::is_current_user_can_edit( $object->ID ) ) { return false; } $document = Plugin::$instance->documents->get( $object->ID ); if ( ! $document ) { return false; } $document->set_is_built_with_elementor( false ); return true; }, ] ); } /** * @since 2.1.0 * @access public */ public function enqueue_assets() { $document = Plugin::$instance->documents->get( get_the_ID() ); if ( ! $document || ! $document->is_editable_by_current_user() ) { return; } $this->is_gutenberg_editor_active = true; $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script( 'elementor-gutenberg', ELEMENTOR_ASSETS_URL . 'js/gutenberg' . $suffix . '.js', [ 'jquery' ], ELEMENTOR_VERSION, true ); $elementor_settings = [ 'isElementorMode' => $document->is_built_with_elementor(), 'editLink' => $document->get_edit_url(), ]; Utils::print_js_config( 'elementor-gutenberg', 'ElementorGutenbergSettings', $elementor_settings ); } /** * @since 2.1.0 * @access public */ public function print_admin_js_template() { if ( ! $this->is_gutenberg_editor_active ) { return; } ?> ID ) ) { return false; } if ( ! static::is_built_with_elementor( $post ) ) { return false; } if ( static::is_gutenberg_in_post( $post ) ) { return false; } return true; } private static function is_built_with_elementor( $post ) : bool { $document = Plugin::$instance->documents->get( $post->ID ); if ( ! $document || ! $document->is_built_with_elementor() ) { return false; } return true; } private static function is_gutenberg_in_post( $post ) : bool { if ( has_blocks( $post ) ) { return true; } if ( static::current_theme_is_fse_theme() ) { return true; } return false; } private static function current_theme_is_fse_theme() : bool { if ( function_exists( 'wp_is_block_theme' ) ) { return (bool) wp_is_block_theme(); } if ( function_exists( 'gutenberg_is_fse_theme' ) ) { return (bool) gutenberg_is_fse_theme(); } return false; } }