| 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 = dirname( __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 |
// Load the TablePress style customizations for the Freemius Pricing screen. |
| 25 |
tb_tp_fs()->add_filter( |
| 26 |
'pricing/css_path', |
| 27 |
static function ( $path ) /* No return type declaration or type hints, due to required PHP compatibility of this file! */ { |
| 28 |
$path = dirname( __DIR__ ) . '/admin/css/build/freemius-pricing.css'; |
| 29 |
return $path; |
| 30 |
} // No trailing comma in function call, due to required PHP compatibility of this file! |
| 31 |
); |
| 32 |
|
| 33 |
// Hide the "Pricing" menu entry for users with a valid and active premium license. |
| 34 |
tb_tp_fs()->add_filter( |
| 35 |
'is_submenu_visible', |
| 36 |
static function ( $is_visible, $menu_id ) /* No return type declaration or type hints, due to required PHP compatibility of this file! */ { |
| 37 |
if ( 'pricing' === $menu_id ) { |
| 38 |
$is_visible = ! TABLEPRESS_IS_PLAYGROUND_PREVIEW && ! tb_tp_fs()->is_paying_or_trial() && current_user_can( 'tablepress_list_tables' ); |
| 39 |
} |
| 40 |
return $is_visible; |
| 41 |
}, |
| 42 |
10, |
| 43 |
2 // No trailing comma in function call, due to required PHP compatibility of this file! |
| 44 |
); |
| 45 |
|
| 46 |
// Show only annual but not calculated monthly prices on the "Pricing" page. |
| 47 |
tb_tp_fs()->add_filter( 'pricing/show_annual_in_monthly', '__return_false' ); |
| 48 |
|
| 49 |
// Determine the default currency based on the top-level domain (TLD) of the site URL. |
| 50 |
tb_tp_fs()->add_filter( |
| 51 |
'default_currency', |
| 52 |
static function ( $currency ) /* No return type declaration or type hints, due to required PHP compatibility of this file! */ { |
| 53 |
$host = wp_parse_url( site_url(), PHP_URL_HOST ); |
| 54 |
if ( is_string( $host ) ) { |
| 55 |
$tld = strtolower( pathinfo( $host, PATHINFO_EXTENSION ) ); |
| 56 |
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 ) ) { |
| 57 |
$currency = 'eur'; |
| 58 |
} |
| 59 |
} |
| 60 |
return $currency; |
| 61 |
} // No trailing comma in function call, due to required PHP compatibility of this file! |
| 62 |
); |
| 63 |
|
| 64 |
// Hide the tabs navigation on Freemius screens. |
| 65 |
tb_tp_fs()->add_filter( 'hide_account_tabs', '__return_true' ); |
| 66 |
|
| 67 |
// Use different arrow icons in the admin menu. |
| 68 |
tb_tp_fs()->override_i18n( array( |
| 69 |
'symbol_arrow-left' => '←', |
| 70 |
'symbol_arrow-right' => '→', |
| 71 |
) ); |
| 72 |
|