| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Modules\AdminFooter; |
| 4 |
|
| 5 |
/** |
| 6 |
* WP admin footer on FluentCart screens: a quiet feedback link on the left, |
| 7 |
* the FluentCart version on the right. Like FluentCRM, the Pro version is added |
| 8 |
* only when Pro is active and its version differs from Core's. |
| 9 |
*/ |
| 10 |
class AdminFooter |
| 11 |
{ |
| 12 |
public const FEEDBACK_URL = 'https://wordpress.org/support/plugin/fluent-cart/reviews/#new-post'; |
| 13 |
|
| 14 |
/** |
| 15 |
* Called only on the FluentCart admin page (see MenuHandler::register()). |
| 16 |
*/ |
| 17 |
public function register(): void |
| 18 |
{ |
| 19 |
add_filter('admin_footer_text', [$this, 'filterFooterText']); |
| 20 |
// After core_update_footer (priority 10) so this replaces the WordPress version. |
| 21 |
add_filter('update_footer', [$this, 'filterUpdateFooter'], 11); |
| 22 |
} |
| 23 |
|
| 24 |
public function filterFooterText($text): string |
| 25 |
{ |
| 26 |
return sprintf( |
| 27 |
'<span id="footer-thankyou">%s</span>', |
| 28 |
sprintf( |
| 29 |
/* translators: %1$s: opening link tag to the FluentCart reviews page on WordPress.org, %2$s: closing link tag */ |
| 30 |
esc_html__('Enjoying FluentCart? %1$sTell us what you think%2$s', 'fluent-cart'), |
| 31 |
'<a href="' . esc_url(self::FEEDBACK_URL) . '" target="_blank" rel="noopener noreferrer">', |
| 32 |
'</a>' |
| 33 |
) |
| 34 |
); |
| 35 |
} |
| 36 |
|
| 37 |
public function filterUpdateFooter($text): string |
| 38 |
{ |
| 39 |
return esc_html(self::getVersionLabel(self::getProVersion())); |
| 40 |
} |
| 41 |
|
| 42 |
public static function getVersionLabel(?string $proVersion): string |
| 43 |
{ |
| 44 |
$label = FLUENTCART_VERSION; |
| 45 |
|
| 46 |
if ($proVersion && $proVersion !== FLUENTCART_VERSION) { |
| 47 |
/* translators: %s: FluentCart Pro version number */ |
| 48 |
$label .= ' & ' . sprintf(__('Pro %s', 'fluent-cart'), $proVersion); |
| 49 |
} |
| 50 |
|
| 51 |
return $label; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Pro version only while FluentCart Pro is active (its constant is defined on load). |
| 56 |
*/ |
| 57 |
public static function getProVersion(): ?string |
| 58 |
{ |
| 59 |
return defined('FLUENTCART_PRO_PLUGIN_VERSION') ? (string)FLUENTCART_PRO_PLUGIN_VERSION : null; |
| 60 |
} |
| 61 |
} |
| 62 |
|