Call plugin_dir_url() in Package::get_url() instead of from its constructor. (https://github.com/woocommerce/woocommerce-blocks/pull/6260)

This commit is contained in:
Shendy 2022-04-14 23:28:32 +07:00 committed by GitHub
parent 4d3c609a3c
commit 19dfae3dcc
1 changed files with 5 additions and 3 deletions

View File

@ -52,9 +52,6 @@ class Package {
$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' );
}
/**
@ -87,6 +84,11 @@ class Package {
* @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;
}