| @@ -4,8 +4,16 @@ | ||
| 4 | 4 | |
| 5 | 5 | use Tableberg\Patterns\RegisterPatterns; |
| 6 | 6 | |
| 7 | 7 | class Assets { |
| 8 | + /** | |
| 9 | + * The frontend view script gates pro features (sorting/search/pagination) | |
| 10 | + * on TABLEBERG_CFG.IS_PRO, so the config must exist on the frontend too. | |
| 11 | + */ | |
| 12 | + public function register_frontend_assets() { | |
| 13 | + self::pass_data_to_js('tableberg-table-view-script'); | |
| 14 | + } | |
| 15 | + | |
| 8 | 16 | public function register_blocks_assets() { |
| 9 | 17 | self::pass_data_to_js('tableberg-table-editor-script'); |
| 10 | 18 | |
| 11 | 19 | $tableberg_patterns = RegisterPatterns::get_all_registered_tableberg_patterns(); |
| @@ -51,17 +59,15 @@ | ||
| 51 | 59 | |
| 52 | 60 | private static function pass_data_to_js(string $handle) { |
| 53 | 61 | $data = [ |
| 54 | 62 | 'plugin_url' => TABLEBERG_URL, |
| 63 | + // Pro marks this true only after its licence check succeeds and | |
| 64 | + // its runtime extensions actually boot. The version constant only | |
| 65 | + // proves that the add-on PHP file was loaded. | |
| 66 | + 'IS_PRO' => (bool) apply_filters( | |
| 67 | + 'tableberg/is_pro_runtime_active', | |
| 68 | + false | |
| 69 | + ), | |
| 55 | 70 | ]; |
| 56 | - $has_pro_addon = defined('TABLEBERG_PRO_VERSION'); | |
| 57 | - global $tp_fs; | |
| 58 | - if (isset($tp_fs)) { | |
| 59 | - $data['IS_PRO'] = $has_pro_addon | |
| 60 | - || ($tp_fs->is__premium_only() | |
| 61 | - && $tp_fs->can_use_premium_code()); | |
| 62 | - } else { | |
| 63 | - $data['IS_PRO'] = $has_pro_addon; | |
| 64 | - } | |
| 65 | 71 | wp_localize_script($handle, 'TABLEBERG_CFG', $data); |
| 66 | 72 | } |
| 67 | 73 | } |