Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Call plugin_dir_url() in Package::get_url() instead of from its const…
Browse files Browse the repository at this point in the history
…ructor.
  • Loading branch information
shendy-a8c authored and senadir committed Apr 14, 2022
1 parent 520997b commit 09f4370
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Domain/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ public function __construct( $version, $plugin_path, FeatureGating $feature_gati
$this->version = $version;
$this->path = $plugin_path;
$this->feature_gating = $feature_gating;

// Append index.php so WP does not return the parent directory.
$this->plugin_dir_url = plugin_dir_url( $this->path . '/index.php' );
}

/**
Expand Down Expand Up @@ -87,6 +84,11 @@ public function get_path( $relative_path = '' ) {
* @return string
*/
public function get_url( $relative_url = '' ) {
if ( ! $this->plugin_dir_url ) {
// Append index.php so WP does not return the parent directory.
$this->plugin_dir_url = plugin_dir_url( $this->path . '/index.php' );
}

return $this->plugin_dir_url . $relative_url;
}

Expand Down

0 comments on commit 09f4370

Please sign in to comment.