| 1 |
<?php |
| 2 |
/** |
| 3 |
* Brand-aware helper for display strings. |
| 4 |
* |
| 5 |
* The Easy Invoice Pro License page (and a handful of other places) hard- |
| 6 |
* code the literal text "MatrixAddons" / "matrixaddons.com" in user-visible |
| 7 |
* messages — "your license key from your MatrixAddons.com account", |
| 8 |
* "HTTP request sent to matrixaddons.com", etc. When an agency uses the |
| 9 |
* White-Label addon to rebrand the plugin, these strings would otherwise |
| 10 |
* leak the original brand back to the end-client. |
| 11 |
* |
| 12 |
* IMPORTANT: this helper deliberately does NOT change the actual license- |
| 13 |
* server URL. The EDD license check still hits matrixaddons.com because |
| 14 |
* that's where the license actually lives. Changing the URL would break |
| 15 |
* activation. Only the display-side text changes. |
| 16 |
* |
| 17 |
* Filters lets the White-Label addon override the brand strings; without it, |
| 18 |
* defaults are returned. |
| 19 |
*/ |
| 20 |
|
| 21 |
if (!defined('ABSPATH')) { |
| 22 |
exit; |
| 23 |
} |
| 24 |
|
| 25 |
if (!function_exists('easy_invoice_brand_name')) { |
| 26 |
/** |
| 27 |
* Brand display name. Defaults to "MatrixAddons". Override via |
| 28 |
* the White-Label addon's `plugin_name` or `author_name` settings. |
| 29 |
*/ |
| 30 |
function easy_invoice_brand_name(): string { |
| 31 |
$default = 'MatrixAddons'; |
| 32 |
if (class_exists('\\EasyInvoicePro\\Addons\\WhiteLabel\\WhiteLabel')) { |
| 33 |
$s = \EasyInvoicePro\Addons\WhiteLabel\WhiteLabel::get(); |
| 34 |
if (!empty($s['author_name'])) return $s['author_name']; |
| 35 |
if (!empty($s['plugin_name'])) return $s['plugin_name']; |
| 36 |
} |
| 37 |
return (string) apply_filters('easy_invoice_brand_name', $default); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
if (!function_exists('easy_invoice_brand_domain')) { |
| 42 |
/** |
| 43 |
* Brand display domain (for "your account at <domain>" copy). Defaults |
| 44 |
* to "matrixaddons.com". Override via the White-Label addon's |
| 45 |
* `plugin_url` or `author_url` settings (host part is extracted). |
| 46 |
*/ |
| 47 |
function easy_invoice_brand_domain(): string { |
| 48 |
$default = 'matrixaddons.com'; |
| 49 |
if (class_exists('\\EasyInvoicePro\\Addons\\WhiteLabel\\WhiteLabel')) { |
| 50 |
$s = \EasyInvoicePro\Addons\WhiteLabel\WhiteLabel::get(); |
| 51 |
foreach (['plugin_url', 'author_url'] as $key) { |
| 52 |
if (!empty($s[$key])) { |
| 53 |
$host = wp_parse_url($s[$key], PHP_URL_HOST); |
| 54 |
if ($host) return $host; |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
return (string) apply_filters('easy_invoice_brand_domain', $default); |
| 59 |
} |
| 60 |
} |
| 61 |
|