| 1 |
<?php |
| 2 |
/** |
| 3 |
* Freemius plugin filters for TablePress. |
| 4 |
* |
| 5 |
* Note: This file must not contain PHP code that does not run on PHP < 7.4! |
| 6 |
* |
| 7 |
* @package TablePress |
| 8 |
* @author Tobias Bäthge |
| 9 |
* @since 3.0.0 |
| 10 |
*/ |
| 11 |
|
| 12 |
// Prohibit direct script loading. |
| 13 |
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); |
| 14 |
|
| 15 |
// Load the TablePress plugin icon for the Freemius opt-in/activation screen. |
| 16 |
tb_tp_fs()->add_filter( |
| 17 |
'plugin_icon', |
| 18 |
static function ( $icon ) /* No return type declaration or type hints, due to required PHP compatibility of this file! */ { |
| 19 |
$icon = __DIR__ . '/admin/img/tablepress-icon.svg'; |
| 20 |
return $icon; |
| 21 |
} // No trailing comma in function call, due to required PHP compatibility of this file! |
| 22 |
); |
| 23 |
|
| 24 |
// Hide the "Pricing" menu entry for users with a valid and active premium license. |
| 25 |
tb_tp_fs()->add_filter( |
| 26 |
'is_submenu_visible', |
| 27 |
static function ( $is_visible, $menu_id ) /* No return type declaration or type hints, due to required PHP compatibility of this file! */ { |
| 28 |
if ( 'pricing' === $menu_id ) { |
| 29 |
$is_visible = ! TABLEPRESS_IS_PLAYGROUND_PREVIEW && ! tb_tp_fs()->is_paying_or_trial(); |
| 30 |
} |
| 31 |
return $is_visible; |
| 32 |
}, |
| 33 |
10, |
| 34 |
2 // No trailing comma in function call, due to required PHP compatibility of this file! |
| 35 |
); |
| 36 |
|
| 37 |
// Show only annual but not calculated monthly prices on the "Pricing" page. |
| 38 |
tb_tp_fs()->add_filter( 'pricing/show_annual_in_monthly', '__return_false' ); |
| 39 |
|
| 40 |
// Determine the default currency based on the top-level domain (TLD) of the site URL. |
| 41 |
tb_tp_fs()->add_filter( |
| 42 |
'default_currency', |
| 43 |
static function ( $currency ) /* No return type declaration or type hints, due to required PHP compatibility of this file! */ { |
| 44 |
$host = wp_parse_url( site_url(), PHP_URL_HOST ); |
| 45 |
if ( is_string( $host ) ) { |
| 46 |
$tld = strtolower( pathinfo( $host, PATHINFO_EXTENSION ) ); |
| 47 |
if ( in_array( $tld, array( 'at', 'be', 'bg', 'cy', 'cz', 'de', 'dk', 'ee', 'es', 'fi', 'fr', 'gr', 'hu', 'ie', 'it', 'lt', 'lu', 'lv', 'mt', 'nl', 'pl', 'pt', 'ro', 'se', 'si', 'sk', 'uk' ), true ) ) { |
| 48 |
$currency = 'eur'; |
| 49 |
} |
| 50 |
} |
| 51 |
return $currency; |
| 52 |
} // No trailing comma in function call, due to required PHP compatibility of this file! |
| 53 |
); |
| 54 |
|
| 55 |
tb_tp_fs()->add_filter( |
| 56 |
'templates/pricing.php', |
| 57 |
static function ( $template ) /* No return type declaration or type hints, due to required PHP compatibility of this file! */ { |
| 58 |
$style = <<<CSS |
| 59 |
<style> |
| 60 |
#fs_pricing_app .fs-packages-tab, |
| 61 |
#fs_pricing_app .fs-section--packages .fs-packages-nav.fs-has-next-plan:after, |
| 62 |
#fs_pricing_app .fs-package.fs-free-plan, |
| 63 |
#fs_pricing_app .fs-selected-pricing-amount-fraction, |
| 64 |
#fs_pricing_app .fs-section--currencies { |
| 65 |
display: none !important; |
| 66 |
} |
| 67 |
#fs_pricing_app .fs-packages { |
| 68 |
width: 80% !important; |
| 69 |
min-width: 590px; |
| 70 |
max-width: 860px; |
| 71 |
} |
| 72 |
#fs_pricing_app .fs-packages .fs-package { |
| 73 |
width: 50% !important; |
| 74 |
} |
| 75 |
#fs_pricing_app .fs-section--packages .fs-packages-nav { |
| 76 |
width: 100% !important; |
| 77 |
} |
| 78 |
#fs_pricing_app .fs-package .fs-plan-description { |
| 79 |
text-transform: none; |
| 80 |
text-wrap: balance; |
| 81 |
padding: 0 20px; |
| 82 |
} |
| 83 |
</style> |
| 84 |
CSS; |
| 85 |
return $style . $template; |
| 86 |
} // No trailing comma in function call, due to required PHP compatibility of this file! |
| 87 |
); |
| 88 |
|
| 89 |
// Hide the tabs navigation on Freemius screens. |
| 90 |
tb_tp_fs()->add_filter( 'hide_account_tabs', '__return_true' ); |
| 91 |
|
| 92 |
// Use different arrow icons in the admin menu. |
| 93 |
tb_tp_fs()->override_i18n( array( |
| 94 |
'symbol_arrow-left' => '←', |
| 95 |
'symbol_arrow-right' => '→', |
| 96 |
) ); |
| 97 |
|