diff --git a/modules/ppcp-paylater-block/src/PayLaterBlockModule.php b/modules/ppcp-paylater-block/src/PayLaterBlockModule.php index bc6d45123..0e528ae80 100644 --- a/modules/ppcp-paylater-block/src/PayLaterBlockModule.php +++ b/modules/ppcp-paylater-block/src/PayLaterBlockModule.php @@ -102,7 +102,7 @@ class PayLaterBlockModule implements ServiceModule, ExtendingModule, ExecutableM ); register_block_type( - dirname( realpath( __FILE__ ) ?: __FILE__, 2 ), + $c->get( 'ppcp.path-to-plugin-folder' ) . 'modules/ppcp-paylater-block/', array( 'render_callback' => function ( array $attributes ) use ( $c ) { $renderer = $c->get( 'paylater-block.renderer' ); diff --git a/modules/ppcp-paylater-wc-blocks/src/PayLaterWCBlocksModule.php b/modules/ppcp-paylater-wc-blocks/src/PayLaterWCBlocksModule.php index a3769cb31..c44028c95 100644 --- a/modules/ppcp-paylater-wc-blocks/src/PayLaterWCBlocksModule.php +++ b/modules/ppcp-paylater-wc-blocks/src/PayLaterWCBlocksModule.php @@ -192,10 +192,10 @@ class PayLaterWCBlocksModule implements ServiceModule, ExtendingModule, Executab return; } - $path = realpath( __FILE__ ) ?: __FILE__; + $path_to_module_js_folder = $c->get( 'ppcp.path-to-plugin-folder' ) . 'modules/ppcp-paylater-wc-blocks/resources/js/'; register_block_type( - dirname( $path, 2 ) . '/resources/js/CartPayLaterMessagesBlock', + $path_to_module_js_folder . 'CartPayLaterMessagesBlock', array( 'render_callback' => function ( array $attributes ) use ( $c ) { return PayLaterWCBlocksUtils::render_paylater_block( @@ -209,7 +209,7 @@ class PayLaterWCBlocksModule implements ServiceModule, ExtendingModule, Executab ); register_block_type( - dirname( $path, 2 ) . '/resources/js/CheckoutPayLaterMessagesBlock', + $path_to_module_js_folder . 'CheckoutPayLaterMessagesBlock', array( 'render_callback' => function ( array $attributes ) use ( $c ) { return PayLaterWCBlocksUtils::render_paylater_block( diff --git a/modules/ppcp-settings/src/Service/ScriptDataHandler.php b/modules/ppcp-settings/src/Service/ScriptDataHandler.php index 743578158..41c799799 100644 --- a/modules/ppcp-settings/src/Service/ScriptDataHandler.php +++ b/modules/ppcp-settings/src/Service/ScriptDataHandler.php @@ -59,6 +59,8 @@ class ScriptDataHandler { */ protected PartnerAttribution $partner_attribution; + protected string $path_to_module_assets_folder; + /** * ScriptDataHandler constructor. * @@ -69,6 +71,7 @@ class ScriptDataHandler { * @param string $merchant_id The merchant ID. * @param array $button_language_choices The button language choices. * @param PartnerAttribution $partner_attribution The partner attribution object. + * @param string $path_to_module_assets_folder The path to mpdule assets folder. */ public function __construct( Settings $settings, @@ -77,15 +80,17 @@ class ScriptDataHandler { string $store_country, string $merchant_id, array $button_language_choices, - PartnerAttribution $partner_attribution + PartnerAttribution $partner_attribution, + string $path_to_module_assets_folder ) { - $this->settings = $settings; - $this->settings_url = $settings_url; - $this->paylater_is_available = $paylater_is_available; - $this->store_country = $store_country; - $this->merchant_id = $merchant_id; - $this->button_language_choices = $button_language_choices; - $this->partner_attribution = $partner_attribution; + $this->settings = $settings; + $this->settings_url = $settings_url; + $this->paylater_is_available = $paylater_is_available; + $this->store_country = $store_country; + $this->merchant_id = $merchant_id; + $this->button_language_choices = $button_language_choices; + $this->partner_attribution = $partner_attribution; + $this->path_to_module_assets_folder = $path_to_module_assets_folder; } /** @@ -109,7 +114,7 @@ class ScriptDataHandler { * * @psalm-suppress UnresolvableInclude */ - $script_asset_file = require dirname( realpath( __FILE__ ) ?: __FILE__, 3 ) . '/assets/index.asset.php'; + $script_asset_file = require $this->path_to_module_assets_folder . '/index.asset.php'; $module_url = $this->settings_url; @@ -128,7 +133,7 @@ class ScriptDataHandler { ); /** @psalm-suppress UnresolvableInclude */ - $style_asset_file = require dirname( realpath( __FILE__ ) ?: __FILE__, 3 ) . '/assets/style.asset.php'; + $style_asset_file = require $this->path_to_module_assets_folder . '/style.asset.php'; wp_register_style( 'ppcp-admin-settings', diff --git a/modules/ppcp-settings/src/SettingsModule.php b/modules/ppcp-settings/src/SettingsModule.php index 548c12023..4ec089193 100644 --- a/modules/ppcp-settings/src/SettingsModule.php +++ b/modules/ppcp-settings/src/SettingsModule.php @@ -105,7 +105,7 @@ class SettingsModule implements ServiceModule, ExecutableModule { $module_url = $container->get( 'settings.url' ); /** @psalm-suppress UnresolvableInclude */ - $script_asset_file = require dirname( realpath( __FILE__ ) ?: __FILE__, 2 ) . '/assets/switchSettingsUi.asset.php'; + $script_asset_file = require $container->get( 'ppcp.path-to-plugin-folder' ) . 'modules/ppcp-settings/assets/switchSettingsUi.asset.php'; wp_register_script( 'ppcp-switch-settings-ui',