der::class ) ) { $packages_handles = $assets_config->pluck( 'handle' )->all(); Assets_Translation_Loader::for_handles( $packages_handles ); } } public function localize_settings( array $settings ) { $settings['elementPromotionURL'] = Plugin::instance()->license_admin->get_connect_url([ 'utm_source' => '%s', // Will be replaced in the frontend to the widget name 'utm_medium' => 'wp-dash', 'utm_campaign' => 'connect-and-activate-license', 'utm_content' => 'editor-widget-promotion', ]); $settings['dynamicPromotionURL'] = Plugin::instance()->license_admin->get_connect_url( [ 'utm_source' => '%s', // Will be replaced in the frontend to the control name 'utm_medium' => 'wp-dash', 'utm_campaign' => 'connect-and-activate-license', 'utm_content' => 'editor-dynamic-promotion', ] ); if ( ! isset( $settings['promotionWidgets'] ) ) { $settings['promotionWidgets'] = License_API::get_promotion_widgets(); } if ( Display_Conditions_Module::can_use_display_conditions() ) { $settings['displayConditions'] = Display_Conditions_Module::instance() ->get_conditions_manager() ->get_conditions_config(); } return $settings; } public function on_elementor_init() { Plugin::elementor()->editor->notice_bar = new Notice_Bar(); if ( isset( Plugin::elementor()->editor->promotion ) ) { Plugin::elementor()->editor->promotion = new Promotion(); } } public function on_elementor_editor_init() { Plugin::elementor()->common->add_template( __DIR__ . '/template.php' ); } protected function get_assets_base_url() { return ELEMENTOR_PRO_URL; } /** * Map of `@elementor/*` package names to the minimum Elementor Core version * in which the corresponding script handle is registered. * * Keys use the original npm package name (`@elementor/`) so it stays * grep-able against actual `import` statements in the Pro packages. They are * converted to script handles (`elementor-v2-`) at filter time * * NOTE: When adding an entry here, make sure every usage of the package in Pro * source code is guarded by a runtime version check (see e.g. * `isCoreWithEmbeddedDocumentsManager()` in `editor-templates-extended`). */ const VERSION_GATED_CORE_PACKAGES = [ '@elementor/editor-embedded-documents-manager' => '4.2.0', ]; /** * Filter out gated dependencies that are not available in the current Elementor version. * * @return array The filtered dependencies array. */ private function filter_version_gated_dependencies( array $deps ): array { $gated_handles = []; foreach ( self::VERSION_GATED_CORE_PACKAGES as $package => $min_version ) { $gated_handles[ self::package_name_to_script_handle( $package ) ] = $min_version; } return array_filter( $deps, function ( $dep ) use ( $gated_handles ) { if ( ! isset( $gated_handles[ $dep ] ) ) { return true; } return version_compare( ELEMENTOR_VERSION, $gated_handles[ $dep ], '>=' ); } ); } private static function package_name_to_script_handle( string $package_name ): string { $prefix = '@elementor/'; if ( 0 !== strpos( $package_name, $prefix ) ) { return $package_name; } return 'elementor-v2-' . substr( $package_name, strlen( $prefix ) ); } }