Skip to content

Commit

Permalink
fix: add option to get the relative path of the plugin from plugins d…
Browse files Browse the repository at this point in the history
…irectory
  • Loading branch information
Sebastian Thulin committed Dec 3, 2024
1 parent acbe8f6 commit 177f734
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions source/php/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,18 @@ public function getPluginUrl(): string
*
* @return string
*/
public function getPluginPath(): string
public function getPluginPath($relative = false): string
{
return $this->wpService->applyFilters(
$pluginPath = $this->wpService->applyFilters(
$this->createFilterKey(__FUNCTION__),
$this->pluginPath
);

if($relative === true) {
return str_replace(WP_PLUGIN_DIR, '', $pluginPath);
}

return $pluginPath;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion source/php/Config/ConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getDatabaseVersionKey(): string;
public function getDatabaseVersion(): string;
public function getTableName(): string;
public function getPluginUrl(): string;
public function getPluginPath(): string;
public function getPluginPath(bool $relative): string;
public function getPluginFieldsPath(): string;
public function getTextDomain(): string;
public function linkUpdaterBannedPostTypes(): array;
Expand Down
2 changes: 1 addition & 1 deletion source/php/TextDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function loadTextDomain(): void
$this->wpService->loadPluginTextDomain(
$this->config->gettextDomain(),
false,
$this->config->getPluginPath() . 'languages/'
$this->config->getPluginPath(true) . 'languages/'
);
}
}

0 comments on commit 177f734

Please sign in to comment.